wood burning stoves 2.0*
The moose likes JDBC and the fly likes Database connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Database connection" Watch "Database connection" New topic
Author

Database connection

aditya chitre
Greenhorn

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:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String myDB ="jdbcdbcriver={SQLServer};Server=http://xxxx.sldc.sbc.com;Database=abcd.com";
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: 1081

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

    Thanks,
    Shailesh


    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 ]

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

    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
    Greenhorn

    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(JdbcOdbc.java:6958)

    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)

    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3074)

    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:3

    23)

    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)

    at java.sql.DriverManager.getConnection(DriverManager.java:512)

    at java.sql.DriverManager.getConnection(DriverManager.java:171)

    at Java_Excel.main(Java_Excel.java:42)
    aditya chitre
    Greenhorn

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

    Joined: Oct 11, 2000
    Posts: 1134

    Aditye,
    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,
    Avi.
     
    wood burning stoves
     
    subject: Database connection