Zolf
asked on
connect to sql express DB
hello there,
i am trying to connect to a sql server express 2005.the db is on my local computer.but i cannot connect to the db.i can connect to remote db.but not to this.i think i am doing something wrong in giving the server name.when i access the sql server management studio express the sever name is ZOLF\SQLEXPRESS.please help.
mport java.sql.*;
/**
* Microsoft SQL Server JDBC test program
*/
public class Test {
public Test() throws Exception {
// Get connection
Class.forName("com.microso ft.sqlserv er.jdbc.SQ LServerDri ver");
Connection connection = DriverManager.getConnectio n("jdbc:sq lserver:// ZOLF\SQLEX PRESS:1433 ;" + "databaseName=DSL;user=sa; password=1 23456");
if (connection != null) {
System.out.println();
System.out.println("Succes sfully connected");
System.out.println();
// Meta data
DatabaseMetaData meta = connection.getMetaData();
System.out.println("\nDriv er Information");
System.out.println("Driver Name: "
+ meta.getDriverName());
System.out.println("Driver Version: "
+ meta.getDriverVersion());
System.out.println("\nData base Information ");
System.out.println("Databa se Name: "
+ meta.getDatabaseProductNam e());
System.out.println("Databa se Version: "+
meta.getDatabaseProductVer sion());
}
} // Test
public static void main (String args[]) throws Exception {
Test test = new Test();
}
}
i am trying to connect to a sql server express 2005.the db is on my local computer.but i cannot connect to the db.i can connect to remote db.but not to this.i think i am doing something wrong in giving the server name.when i access the sql server management studio express the sever name is ZOLF\SQLEXPRESS.please help.
mport java.sql.*;
/**
* Microsoft SQL Server JDBC test program
*/
public class Test {
public Test() throws Exception {
// Get connection
Class.forName("com.microso
Connection connection = DriverManager.getConnectio
if (connection != null) {
System.out.println();
System.out.println("Succes
System.out.println();
// Meta data
DatabaseMetaData meta = connection.getMetaData();
System.out.println("\nDriv
System.out.println("Driver
+ meta.getDriverName());
System.out.println("Driver
+ meta.getDriverVersion());
System.out.println("\nData
System.out.println("Databa
+ meta.getDatabaseProductNam
System.out.println("Databa
meta.getDatabaseProductVer
}
} // Test
public static void main (String args[]) throws Exception {
Test test = new Test();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.