Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Location
    Timbaktu
    Posts
    185

    Unanswered: java with named instance of sql server

    How to connect to the named instance of SQL Server using Java?
    I had the following code working fine(but with the default instance only)

    SET JAVA_HOME=D:\Program Files\JavaSoft\JRE\1.3.1_03

    "D:\Program Files\JavaSoft\JRE\1.3.1_03\bin\java" -classpath Launcher.jar;Sprinta2000.jar;log4j.jar;activation. jar;mail.jar Launcher -Ddatabase -Uuser -Ppassword -Sserver:1433 -hlocalhost -p9900 -TTrue -VFalse -QK -QS

    But the same code is failing with the named instance:
    SET JAVA_HOME=D:\Program Files\JavaSoft\JRE\1.3.1_03

    "D:\Program Files\JavaSoft\JRE\1.3.1_03\bin\java" -classpath Launcher.jar;Sprinta2000.jar;log4j.jar;activation. jar;mail.jar Launcher -Ddatabase -Uuser -Ppassword -Sserver\instance:1434 -hlocalhost -p9900 -TTrue -VFalse -QK -QS

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    As a workaround, you can request your sysadmin to create a DNS alias for the named instance.

  3. #3
    Join Date
    May 2002
    Location
    Timbaktu
    Posts
    185
    any other idea>?

  4. #4
    Join Date
    Sep 2003
    Posts
    364
    Which JDBC driver are you using? Many don't support named instances so you have to pass the port number in the connection string. However, if you're using Microsoft's JDBC driver SP2 or later you can connect to named instances without specifying the port. Let me know and I'll post a working example for Microsft's JDBC driver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •