Lock wait timeout exceeded; try restarting transaction 是什么原因促成的

Lock wait timeout exceeded; try restarting transaction 是什么原因造成的
Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1604)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1519)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1504)
at sun.reflect.GeneratedMethodAccessor130.invoke(Unknown Source)

------解决方案--------------------
InnoDB等待锁超时错误
解决的办法有两个:
第一:innodb_lock_wait_timeout 锁定等待时间改大
my.ini文件:
#innodb_lock_wait_timeout = 50
修改为
innodb_lock_wait_timeout = 500
第二:把多个查询合并为一个查询执行,可以避免等待解锁时间。前面一个查询执行完毕后后面一个查询获得独占锁并执行。