Message Boards Message Boards

0
|
3100 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

How Can I Stop MS SQL Timing Out on First Connection Attempts?

Posted 9 years ago

Pretty much every time I launch a new Mathematica session and attempt a connection to my MS SQL database — which lives across a network connected by RJ45 cable — the first attempt or two at connecting time out, then things work fine.

I connect as follows:

sqlGetConnection[sqlDatabase_] := Module[{sqlConnectionString},
  sqlConnectionString = StringJoin[
    "jdbc:jtds:sqlserver://",
    sqlServerName,
    sqlPortNumber,
    If[StringLength[sqlDatabase] > 0, "/", ""],
    sqlDatabase, 
    ";instance=",
    sqlServerInstance];

    OpenSQLConnection[JDBC["net.sourceforge.jtds.jdbc.Driver", sqlConnectionString], "Username" -> sqlUserName, "Password" -> sqlPassword]
  ]

Note it is not the case that the server is not running and has to start on the first call: Once I establish a connection with the database, all works fine. Then I quit Mathematica, relaunch it, and I get the same timeout problem. So somehow, it seems related to launching Mathematica, not SQL server.

This occurs in several Mathematica programs I have written, where I use SQL. I don’t keep the connection open for the life of a session. Typically, I Open-Do Something-Close for each SQL call. I religiously close the connection behind myself.

This is the typical error message:

JDBC::error: Network error IOException: Operation timed out >>

Versions: MS SQL 2012, Mathematica (on a Mac) 10.2.

Any suggestions?

  • Brad
POSTED BY: Brad Varey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract