Proxy > Gmail Facebook Yahoo!

Connect to Microsoft SQL Server from Java



Here is the way you can connect to your Microsoft SQL Server 2005 from your java application via JDBC.
First you need to download the Microsoft SQL Server 2005 JDBC Driver.
You will get sqljdbc.jar which is all you needed. As a java programmer, you know how to use this, right? ;)
You will get a user manual along with this download. Follow the instructions. Or here is a sample code for your quick reference:







Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://
servernameSQLEXPRESSinstance;database=yourdatabase;user=your username");
Statement stmt = conn.createStatement();
 
String qry = "SELECT * FROM yourtable";
ResultSet rs = stmt.executeQuery(qry);
 
while (rs.next()) {
    // code;
}


Responses

0 Respones to "Connect to Microsoft SQL Server from Java"


Send mail to your Friends.  

Expert Feed

 
Return to top of page Copyright © 2011 | My Code Logic Designed by Suneel Kumar