I want to re-execute the query whenever SQLException occurs and sometime I get the Exception of
SQLException occurred... com.mysql.jdbc.exceptions.jdbc4.
MySQLTransactionRollbackExceptionDeadlock
found when trying to get lock; try restarting transaction
My code is below. The database is MySQL InnoDB .. Please suggest...
String sqlquery = "UPDATE tbl_users SET abill=?"
+ " WHERE uid=? AND sms='2'";
PreparedStatement preStatement=null;
try{
con.setAutoCommit(false);
preStatement=con.prepareStatement(sqlquery);
preStatement.setString(1,billpush);
preStatement.setString(2,uid);
preStatement.executeUpdate();
con.commit();
}
catch(SQLException sE)
{
log.error("SQLException occurred... "+sE);
con.rollback();
}
finally {
if (preStatement != null) {
preStatement.close();
}
}