3
$\begingroup$

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

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

how and where do I set autoReconnect to be True?

$\endgroup$

1 Answer 1

1
$\begingroup$

Additional connection properties are specified as options to OpenSQLConnection.

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.

$\endgroup$
2
  • $\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$ 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
    Oct 12, 2017 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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