larrybuntus larrybuntus - 4 months ago 8
MySQL Question

How to update data in MySql table with grails?

I have tried for days without success to update the records in my

MySQL
database using grails. I always get a
java.sql.SQLException
which is caused by:

Lock wait timeout exceeded

Here is the code I am using:

def campaignUpdater(id, details){
def dbData = Campaigns.get(id)
if(dbData){
dbData.totalSent = details.totalSent
dbData.totalQueued = details.totalQueued
dbData.totalFailed = details.totalFailed
dbData.uniqueClickers = details.uniqueClickers
dbData.opened = details.opened
dbData.save(flush: true, failOnError: true)
return true
}else
return false
}


I really need help as soon as possible.

Answer

Lock wait timeout exceeded exception is either caused if there is a deadlock and Mysql is unable to detect it, or if you have a very long running query.

You probably have a InnoDB engine problem. Most likely you'll need to kill some processes inorder for your queries to run properly. See these answers for more info.

Comments