i want to design the jbpm process for Online Airline reservation system. as a first step i am trying to do process for traveller registration where user will register their details. when they try to register it, it has to store the user endtered details into db in different table instead.
process that i created.
Start node -> traveller form - > registration task -> end
i have created the table called ARS_traveller in h2 database, under public schema.
in custom work item handler, i have given as below, but it throughing the error as table not found. please suggest the correct procedure to connect to the database an tables.
@Override
public void abortWorkItem(WorkItem arg0, WorkItemManager arg1) {
// TODO Auto-generated method stub
}
@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
Context ctx;
try {
System.out.println("*********From direct connection**************");
Connection conn = this.getDirectConnection();
conn.setAutoCommit(true);
PreparedStatement stmt = conn
.prepareStatement("INSERT INTO ARS_TRAVELLER(NAME,EMAIL,USER_ID,PASSWORD,GENDER,"
+ "AGE,MOBILE_NO,ADDRESS,CREATED_ON,UNIQUECODE,VERIFIED) VALUES(?,?,?,?,?,?,?,?,?,?,?)");
stmt.setString(0, workItem.getParameter("Name").toString());
stmt.setString(1, workItem.getParameter("Email").toString());
stmt.setString(2, workItem.getParameter("UserId").toString());
stmt.setString(3, workItem.getParameter("Password").toString());
stmt.setString(4, workItem.getParameter("Gender").toString());
stmt.setInt(5,
Integer.parseInt(workItem.getParameter("Age").toString()));
stmt.setString(6, workItem.getParameter("MobileNo").toString());
stmt.setString(7, workItem.getParameter("Address").toString());
stmt.setDate(8, new Date((new java.util.Date()).getTime()));
stmt.setString(9, ((new java.util.Date()).getTime() + ""));
stmt.setBoolean(10, false);
stmt.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
manager.completeWorkItem(workItem.getId(), null);
}
private Connection getDirectConnection() {
Connection conn = null;
try {
String url = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1";
Class.forName("org.h2.Driver");
conn = DriverManager.getConnection(url, "sa", "sa");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
return conn;
}