Reputation: 26498
I am very new to Java (I am a pure .net guy). I am trying to do a SQL Server 2008 database connectivity. Now I am using "jTDS" driver for accomplishing my work.
db.dbConnect("jdbc:jtds:sqlserver://XXXXXXX\XXXXXXXX/MyDB","username","password");
What wrong I am doing in the connectivity? I am getting the below error
I know that it may be a simple problem to solve. Thanks in advance
Upvotes: 2
Views: 250
Reputation: 108939
You are confusing the Microsoft SQL Server JDBC driver URL format with that of the jTDS driver.
The format for jTDS is:
jdbc:jtds:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;...]]
In your specific example the correct URL for the database would be:
jdbc:jtds:sqlserver://IIS08TOPSDEVDB1/SmbCommission;instance=IIS08TOPSDEVDB1
Now as you are connecting using the instance name, you need to make sure that the SQL Server Browser service is running, and that the instance is configured to accept TCP/IP connections. If you don't (want to) use the SQL Server Browser service, then make sure the instance is configured at a fixed port and specify that port instead of the instance:
jdbc:jtds:sqlserver://IIS08TOPSDEVDB1:<the-port>/SmbCommission
The other option is to use the Microsoft SQL Server JDBC driver, which has the format:
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
With that format the correct URL would have been:
jdbc:sqlserver://IIS08TOPSDEVDB1\IIS08TOPSDEVDB1;databaseName=SmbCommission
Upvotes: 3