This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Database connection

 
aditya chitre
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
     
    Muhammad Saifuddin
    Ranch Hand
    Posts: 1324
    Android Java Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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 ]
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    aditya chitre
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Where do I get information on type 4 drivers?
     
    Avi Abrami
    Ranch Hand
    Posts: 1141
    1
    Java Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic