Sql Error: -1, Sqlstate: 08000 Not Flushing Record
Technical Background: Groovy 2.5.6 Using Java 8. Mariadb Database. Background: I Have a Report System in Place. Different Reports Are Added to a Database...
Technical background: Groovy 2.5.6 using Java 8. MariaDb database.
Background: I have a report system in place. Different Reports are added to a database table. A job executes every 15 minutes and puts a report into a "In progress" state from a "New" state. Then once the job successfully executes the report is updated to a "Done" state. If any exceptions occur the report will put into a "Error" state.
The problem is that once the job executes the report fails to save. In the logs I can see I get a SQL Error: -1, SQLState: 08000 and (conn=64796) Socket error. This indicated to me that there is a connection issue with the database. This is followed with SQL Error: 1220, SQLState: 08000.
There is a problem with the database connection, which has already been closed. The application is failing to generate a report and update a record.
I put the report again in a "New" state and let the job re-run. The same issue occured again. So I was able to replicate it. I do not really have a clear method to follow to troubleshoot.
How do I resolve this error? Is this related to Java 8?
1 Answer
Did this just started to occur? How were you keeping the connection alive before? One way to do that is the following:
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "myuser"
password = "mypassword"
url = "jdbc:mysql://localhost/mydatabase"
properties {
// Set validation query to keep connection alive
validationQuery = "SELECT 1"
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
validationInterval = 30000
timeBetweenEvictionRunsMillis = 5000
}
}
In this example, the validationQuery is set to "SELECT 1", which is a simple query that will always return a result. This query will be executed every 30 seconds (as specified by validationInterval) to ensure that the connection is still alive.