?
Solved

connect to sql express DB

Posted on 2007-07-31
1
Medium Priority
?
274 Views
Last Modified: 2010-03-19
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();
 }
}
0
Comment
Question by:zolf
1 Comment
 
LVL 42

Accepted Solution

by:
dqmq earned 2000 total points
ID: 19606544
Because "\" is an escape character, try this:

"jdbc:sqlserver://ZOLF\\SQLEXPRESS:1433;"
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question