Connecting to Microsoft SQL with version 10

7

3

After upgrading to version 10, functions relying on a connection to a Microsoft SQL database no longer work. When I attempt to open a connection with something like:

Needs["DatabaseLink`"]
conn = OpenSQLConnection[JDBC["Microsoft SQL Server(jTDS)", "server:port/DBName"],
"Username" -> "user", "Password" -> "pass"]

I receive the error:

JDBC::error: net/sourceforge/jtds/jdbc/Driver : Unsupported major.minor version 51.0

I have verified that this still returns a SQLConnection with Mathematica 9. Other SQL connections (i.e. mysql) are still working for me in Mathematica 10. I still get the error if my machine is not connected to the network, so it can't be an interaction with the remote server. I'm running OS X 10.8.5.

How can I connect to the Microsoft SQL server with the new version of Mathematica?

mdeceglie

Posted 2014-10-15T20:41:02.713

Reputation: 968

Answers

1

The problem was that the init.m file was causing the system version of Java (in my case 6) to override version 7 which shipped with Mathematica 10. The problematic lines in my init.m files were intended to increase the memory available to java:

<<JLink`;
InstallJava[];
ReinstallJava[CommandLine->"java",JVMArguments->"-Xmx4096m"];

The command line option is installing the system default version of java. To remedy this they can be updated to:

<<JLink`;
InstallJava[];
ReinstallJava[CommandLine->"/Applications/Mathematica.app/SystemFiles/Links/JLink/JLink.app/Contents/MacOS/Launcher", JVMArguments->"-Xmx4096m"];

This uses the path to version of java that shipped with Mathematica 10.

mdeceglie

Posted 2014-10-15T20:41:02.713

Reputation: 968

1

I have Mathematica 10 running with SQL Server 2012 and it works fine. This is how I make the connection:

Needs["DatabaseLink`"] (*needed *)
conn = OpenSQLConnection[
  JDBC["Microsoft SQL Server(jTDS)", "servername:portnr/databasename"], 
  "Username" -> "username", "Password" -> "password"]

A SQLConnection object is returned.

Use DatabaseExplorer[] to test different settings if you like working via a userinterface.

need more details if this does not work.

Kind regards,

pvanbijnen

Posted 2014-10-15T20:41:02.713

Reputation: 806

Thanks for the comment, I have updated the questions with some more details. It appears we are both using the same approach but it isn't working for me. – mdeceglie – 2014-10-17T15:12:09.380