I sometimes leave long computations running overnight and return in the morning to find that my database connection has timed out. I typically have to kill the kernel and launch a new database connection in order to be sure everything works properly.

The lead error after a timeout suggests that I use

"the Connector/J connection property 'autoReconnect=true' to avoid this problem"

But Wolfram's documentation, to the best that I can find, never mentions this option. Given a connection command like

 "Username" -> XXXXXX,
 "Password" -> YYYYYY]

how and where do I set autoReconnect to be True?


1 Answer 1


Additional connection properties are specified as options to OpenSQLConnection.

 JDBC["MySQL(Connector/J)", "localhost:3306/sample_schema"], 
 "Username" -> "XXXXXX",
 "Password" -> "YYYYYY",
 "autoReconnect" -> "true"]

I don't think the documentation explicitly states this anywhere. You could contact WRI and suggest they add this to the OpenSQLConnection documentation.

Hope this helps.

  • $\begingroup$ Unfortunately, this doesn't seem to work. JDBC::error: The last packet successfully received from the server was 61,877,751 milliseconds ago. The last packet sent successfully to the server was 61,877,765 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. $\endgroup$ Commented Oct 12, 2017 at 14:33
  • $\begingroup$ @MichaelStern You need to look at the connection documentation for your driver to determine which option (or set of options) you need to set to get the behavior you want. From the message it looks as if you need the wait_timeout option. It is best to check the docs so you set the correct one(s). $\endgroup$
    – Edmund
    Commented Oct 12, 2017 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.