Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Posts
    11

    Unhappy Unanswered: cannot connect to database with jdbc:odbc

    Hi everyone,

    I'm trying to connect oracle database running on win 2000 workstation. The program used is was this

    import java.sql.*;
    public class OnlineStoreConnection
    {
    public static void main(String a[])
    {
    String data ="jdbcdbc:student";
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con =DriverManager.getConnection(
    "data", "student", "student");
    Statement st = con.createStatement();
    ResultSet rec = st.executeQuery("SELECT FIRSTNAME, LASTNAME"
    + "FROM CUSTOMER" + "WHERE CUST_ID=101");


    System.out.println("CUST_ID\tFISTNAME\tLASTNAME");
    while(rec.next())
    {
    System.out.println(rec.getString(1) + "\t" +
    rec.getString(2) + "\t\t" +
    rec.getString(3));
    }

    st.close();
    } catch(SQLException s)
    {
    System.out.println("SQL Error: " + s.toString() + " "
    + s.getErrorCode() + " "+ s.getSQLState());
    }
    catch(Exception e)
    {
    System.out.println("Error: " + e.toString() + e.getMessage());
    }
    }
    }

    however i get an error that says java.sqlException no sutable driver 08001

    thank you in advance

  2. #2
    Join Date
    Feb 2003
    Location
    Other side of the ocean
    Posts
    6
    I would expect that the JDBC-ODBC Bridge Driver isn't in your classpath

  3. #3
    Join Date
    Mar 2003
    Location
    East Grinstead ,UK
    Posts
    19

    Re: cannot connect to database with jdbc:odbc

    You've got the wrong database driver , try this
    String data = "jdbcracle:student"
    Class.forName ("oracle.jdbc.driver.OracleDriver")
    Originally posted by mchristmas
    Hi everyone,

    I'm trying to connect oracle database running on win 2000 workstation. The program used is was this

    import java.sql.*;
    public class OnlineStoreConnection
    {
    public static void main(String a[])
    {
    String data ="jdbcdbc:student";
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con =DriverManager.getConnection(
    "data", "student", "student");
    Statement st = con.createStatement();
    ResultSet rec = st.executeQuery("SELECT FIRSTNAME, LASTNAME"
    + "FROM CUSTOMER" + "WHERE CUST_ID=101");


    System.out.println("CUST_ID\tFISTNAME\tLASTNAME");
    while(rec.next())
    {
    System.out.println(rec.getString(1) + "\t" +
    rec.getString(2) + "\t\t" +
    rec.getString(3));
    }

    st.close();
    } catch(SQLException s)
    {
    System.out.println("SQL Error: " + s.toString() + " "
    + s.getErrorCode() + " "+ s.getSQLState());
    }
    catch(Exception e)
    {
    System.out.println("Error: " + e.toString() + e.getMessage());
    }
    }
    }

    however i get an error that says java.sqlException no sutable driver 08001

    thank you in advance

Posting Permissions

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