SQL Exception
Hi ,
I am using MySql as database for my application. But some times i am getting the following exception frequently.
Here is the excpetionMessage
java.sql.SQLException: Deadlock found when trying to get lock; Try restarting transaction message from server:"Lock wait timeout exceeded; try restarting transaction"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2001)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1168)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1279)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2281)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1825)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1667)
Can you guys tell me why this exception is comming frequently.
Here is my code
protectedvoid updateRuleDB(Connection dbcon, Rule rule)
throws SQLException
{
System.out.println("Rule in rule.getxrule"+rule.getXRule());
PreparedStatement ps = dbcon.prepareStatement(Query.MODIFY_RULE_QUERY);
// NAME
ps.setString(1, rule.getName());
// PRIORITY
ps.setInt(2, rule.getPriority());
// STATUS
ps.setString(3, rule.getStatus());
// TODO Convert this into a method to allow future CLOB datatype
// EXPRESSION
ps.setString(4, rule.getExpression());
//Xrule
ps.setString(5, rule.getXRule());
// RULESET_ID
ps.setString(6, rule.getRuleSetId());
// ID
ps.setString(7, rule.getId());
// Run Query
ps.executeUpdate();
// Close 'ps'
ps.close();
regards,
Krishna.

