PDA

Click to See Complete Forum and Search --> : connectivity of sql with java


imrans
Feb 6th, 2006, 12:33 AM
what is the connectivity code of sql server with java

Andy_Hollywood
Feb 6th, 2006, 05:33 AM
You need to get the SQL Server JAR from somewhere, then this is the basic setup:



Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); // this statically initialises the driver.

String url = "jdbc:microsoft:sqlserver://<host>:<port>;DatabaseName=<databasename>";
String username = "sa";
String password = "yourpassword"
Connection c = DriverManager.getConnection(this.url, username, password);


That should do it for you...