Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases and the fly likes Database connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Database connection" Watch "Database connection" New topic

Database connection

aditya chitre

Joined: May 13, 2008
Posts: 4
How to connect to a database on an IBM HTTP server using JDBC?

I am using the following code:

String myDB ="jdbcdbcriver={SQLServer};Server=;";
Connection con = DriverManager.getConnection(myDB,"","");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from customer");

But I am getting an error.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082

You are loading Type 1 driver to create a OBBC connection.
  • Did you Set up ODBC Data Source .
  • connection string for jdbc-odbc connection is jdbcdbc:dsnName

  • where dsnName is the odbc datasource name


    Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
    Muhammad Saifuddin
    Ranch Hand

    Joined: Dec 06, 2005
    Posts: 1321

    But I am getting an error.

    what error? would you please paste here.. so it may helps other to find a solution for you..

    and this entry might help you in creating a dynamic DSN

    and please use UBB Code to make your post more readable...
    [ September 14, 2008: Message edited by: Muhammad Saifuddin ]

    [Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
    Paul Sturrock

    Joined: Apr 14, 2004
    Posts: 10336

    To follow on from what Shailesh Chandra has already written, are you aware that there are proper type-4 JDBC drivers available from SQL Server? No need to use the JDBC-ODBC bridge.

    JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    aditya chitre

    Joined: May 13, 2008
    Posts: 4
    This is the error I am getting:
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][Named Pipes]Specified SQL server not found.

    at sun.jdbc.odbc.JdbcOdbc.createSQLException(

    at sun.jdbc.odbc.JdbcOdbc.standardError(

    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(

    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(


    at sun.jdbc.odbc.JdbcOdbcDriver.connect(

    at java.sql.DriverManager.getConnection(

    at java.sql.DriverManager.getConnection(

    at Java_Excel.main(
    aditya chitre

    Joined: May 13, 2008
    Posts: 4
    Where do I get information on type 4 drivers?
    Avi Abrami
    Ranch Hand

    Joined: Oct 11, 2000
    Posts: 1141

    You asked:

    Where do I get information on type 4 drivers?

    Did you try searching the Internet?
    (And pardon me if I am stating the obvious.)

    Good Luck,
    I agree. Here's the link:
    subject: Database connection
    jQuery in Action, 3rd edition