Reputation: 11
I've seen lots of sites online that have connection strings for languages other than Java to connect to SQL Server Native Client 10.0 OLE DB Provider, such as:
"Provider=SQLNCLI10;Server=myServer;Database=myDatabse;UID=myUID;PWD=myPWD"
And I've been able to connect to regular SQL server (not Native Client) in a different way, using a url string such as this (I'm excluding all the try/catch and other things you need to actually make this work for simplicity):
String myDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String myUrl =
"jdbc:sqlserver://localhost:1433;DatabaseName=myDatabase";
Connection myConnection = DriverManager.getConnection(url, myUN, myPWD);
But what connection string should I put into Java, because one of these only works in different languages and the other one isn't designed to connect to Native Client?
Upvotes: 0
Views: 1360
Reputation: 11
In the end this is what worked:
String myDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String myUrl = "jdbc:sqlserver://myServerName:1433;DatabaseName=myDatabase";
Connection myConnection = DriverManager.getConnection(myUrl, myUN, myPWD);
Upvotes: 1