» An ultimate catalog of computer data
Forum posts for ps2.exe
Attempting to enter values to database tables using jdbc transaction
I'm attempting to enter a set of values to tables reservation,resdetails using database transactions. There are no exceptions thrown, but values are not being entered in to DB.Here i've used utilised java.sql.PreparedStatement.
public boolean addReservation(Reservation res, ArrayList<ReservationDetails> resdetlist) throws Exception {
connection = DBConnection.getDBConnection();
try {
System.out.println('A');
connection.setAutoCommit(false);
PreparedStatement ps1 = connection.prepareStatement('insert into reservation values(?,?,?,?)');
ps1.setString(1, res.getResid());
ps1.setBoolean(2, res.isCheckin_status());
ps1.setString(3, res.getRes_from());
ps1.setString(4, res.getRes_till());
int addedres = ps1.executeUpdate();
System.out.println('addres:' + addedres);
System.out.println('B');
if (addedres > 0) {
for (ReservationDetails resdet : resdetlist) {
//int addedresdet = addReservationDetails(resdet);
PreparedStatement ps2 = connection.prepareStatement('insert into resdetails values(?,?,?,?,?,?)');
ps2.setString(1, resdet.getResid());
ps2.setString(2, resdet.getNic());
ps2.setString(3, resdet.getPayment_id());
ps2.setString(4, resdet.getRoom_no());
ps2.setString(5, resdet.getType_of_accomodation());
ps2.setString(6, resdet.getDate_of_reservation());
int addedresdet = ps2.executeUpdate();
System.out.println('addedresdet:' + addedresdet);
System.out.println('C');
if (addedresdet <= 0) {
System.out.println('D');
connection.rollback();
return false;
}
}
} else {
System.out.println('E');
connection.rollback();
return false;
}
connection.commit();
} catch (Exception ex) {
// ex.printStackTrace();
connection.rollback();
} finally {
connection.setAutoCommit(true);
System.out.println('F');
}
return true;
}
View complete forum thread with replies
Other posts related to ps2.exe
See Related Forum Messages: Follow the Links Below to View Complete Thread
MySQL query SELECT GREATEST int row VALUE beetween limits
netty open 2 port server & 1 port client
Sliding multiple divs left to right with jquery toggle
Timed autosave with Batch
Return a value from PHP to HTML
Related object not saved
Attempting to enter values to database tables using jdbc transaction