Hello there, its a while I returned to blog. Here I will enlist the steps needed to perform for JDBC Connection with MSSQL Server 2008.
Steps:
{
Steps:
- Download the MSSQL Server JDBC Driver from here http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774
- Unzip the folder and you will get three important files - sqljdbc4.jar, sqljdbc.jar and sqljdbc_auth.dll in the \sqljdbc_4.0\enu\auth\x86 folder
- Now put sqljdbc4.jar file in D:\Program Files\Java\jre7\lib\ext whereas my JDK is installed in D drive
- Then put sqljdbc_auth.dll file the D:\Program Files\Java\jre7\bin
- Also add those two paths into the PATH system variables
- Also get the TCP/IP port number of the SQL Srever instance from SQL Server Management Studio
- Now you can check the following code modifying the connection string for you
{
String DbName="stackoverflow_db";
Class.forName( "com.microsoft.sqlserver.jdbc.SQLServerDriver" ).newInstance();
Connection con = DriverManager.getConnection( "jdbc:sqlserver://localhost\\SQLEXPRESS;databaseName="+DbName+";integratedSecurity=true");
System.out.println("Connected to database successfully");
}catch(Exception exc){
System.err.println(exc.getMessage());
}
No comments:
Post a Comment