Java code for connecting MS SQL Server by using SQL Server Authentication

First of all, You will need to add a jar file to your project library as SQL Server 2000 Driver for JDBC Service. My target is SQL Server 2000, it will require the jar file called “sqljdbc4.jar”. This is not supported on Microsoft website now, you can download it here. For other versions of SQL Server, here is the link of SQL Server 2000 Driver for JDBC Service.

The following is the code for connection MS SQL Server and select some records from a testing table.

Read more

Java connect MS SQL Server using windows authentication

To connect MS SQL Server using windows authentication, the first step is to setup ODBC. You can go to Control panel -> Administrative tools -> ODBC. Add a new DSN to connect MS SQL Server using windows authentication account following wizard setup. The second step is the similar with using SQL Server authentication. The only … Read more