Data truncation: Incorrect datetime value: ” for column 2

While using Acitiviti API you might encounter this error which says something like this ### Error updating database. Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: ” for column ‘DEPLOY_TIME_’ at row 1### The error may involve org.activiti.engine.impl.persistence.entity.DeploymentEntity.insertDeployment-Inline### The error occurred while setting parameters### Cause: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: ” for column ‘DEPLOY_TIME_’ at row ...

Add Two Integers without using Arithmetic Operators

Recently came across an interesting question of adding two numbers without using any of the arithmetic operators and thought of giving it a try. The first thought of solving the question was using bit-manipulation operations. The idea was to add the numbers bit-by-bit taking any carry forward (without actually adding them and instead using bit-wise ...

To compare two folders (recursively) in Java 21

Java package com.example; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.security.MessageDigest; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Set; public class Compare { //This can be any folder locations which you want to compare File dir1 = new File("C:\\ComparisonFolder\\master"); File dir2 = new File("C:\\ComparisonFolder\\release"); public static void main(String ...args) { Compare compare = ...

Count Triangles in a Graph 1

The following code implementation counts the number of triangles present in a graph G. For graph representation JUNG API is used but can be extended/ changed to use any other notation by simple means. Java import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import edu.uci.ics.jung.graph.Graph; public class TriangleFinder { private Graph<Integer, String> g; /** * @return The ...

Dijkstra’s Algorithm : Finding all possible shortest paths between two vertices in a graph 4

Dijkstra's Algorithm : Finding all possible shortest paths between two vertices in a graph
The following code implements the Dijkstra’s Shortest Path Algorithm and further extends is to get all possible shortest paths between two vertices. For graph representation we make use of JUNG API, its usage, however, is primarily in visualizing the graph and can be extended easily for any other representation as well. Random Graph Generator code ...

Code for Random Graph Generation G(n,p) 1

Code for Random Graph Generation G(n,p)
Following is the Java code for generating a Random Graph G(n, p) where ‘n’ is the number of nodes/ vertices in the graph and ‘p’ is the probability that any edge will form or not. The code makes use of JUNG API for graph visualization and creation. More About JUNG… Java import java.awt.Dimension; import javax.swing.JFrame; ...

ConcurrentHashMap 1

ConcurrentHashMap
Javadoc says… “A hash table except supporting full concurrency of retrievals and adjustable expected concurrency for updates. This class obeys the same functional specification as Hashtable, and includes versions of methods corresponding to each method of Hashtable. However, even though all operations are thread-safe, retrieval operations do not entail locking, and there is not any ...

Code Jam Fair and Square

This is a solution to the FairAndSquare problem asked in the qualification round of Google Code Jam-2013. Please read the problem statement very carefully as the correctness of solution depends heavily on how you understand and interpret the problem statement. We present here two solutions to the problem one for the small input and the other for the large ...

Waiting for multiple threads to finish

Description: We need to perform four jobs , out of which three jobs are mutually exclusive and should be performed simultaneously(may be getting data from the database using select query)  and the outcome of three jobs will be served as the input for the fourth job.Hence, the fourth job could not be started untill the first three jobs are completed.   Java package com.example; ...

Triangle Test

 Description:          The following program takes three numbers as input and checks to see if these may form a triangle or not.                                  Primary Inputs:    Three numbers Primary Output:    Determine the type of triangle formed by the input numbers (if any). Platform Used:      JDK 1.6 with Notepad.  Java import java.io.*; class TriangleTest { public static void main(String[] args) { Console con = System.console(); ...