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();
 }
}
zolfAsked:
Who is Participating?
 
dqmqCommented:
Because "\" is an escape character, try this:

"jdbc:sqlserver://ZOLF\\SQLEXPRESS:1433;"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.