Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

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.microsoft.sqlserver.jdbc.SQLServerDriver");
        Connection connection = DriverManager.getConnection("jdbc:sqlserver://ZOLF\SQLEXPRESS:1433;" + "databaseName=DSL;user=sa;password=123456");
    if (connection != null) {
     System.out.println();
      System.out.println("Successfully connected");
      System.out.println();
      // Meta data
      DatabaseMetaData meta = connection.getMetaData();
      System.out.println("\nDriver Information");
      System.out.println("Driver Name: "
       + meta.getDriverName());
      System.out.println("Driver Version: "
       + meta.getDriverVersion());
      System.out.println("\nDatabase Information ");
      System.out.println("Database Name: "
       + meta.getDatabaseProductName());
      System.out.println("Database Version: "+
      meta.getDatabaseProductVersion());
    }
 } // Test
 public static void main (String args[]) throws Exception {
  Test test = new Test();
 }
}
ASKER CERTIFIED SOLUTION
Avatar of dqmq
dqmq
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial