Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Posts
    43

    Unanswered: JDBC Connection problem - No suitable driver

    Hi,

    I am getting "SQLException: No suitable driver found for jdbc:sybase:Tds:localhost:5003" error when I am trying to connect to local database using JDBC programming. My program is shown below.

    I am using jconn4.jar by jConnect-7_0. The jar file has been pointed in the classpath. Exact error message is as below.

    Any help is appreciated.
    O/s is Windows XP, Java version is 7 and Sybase ASE version is 15.7

    SQLException: No suitable driver found for jdbc:sybase:Tds:localhost:5003
    SQLState: 08001
    VendorError: 0
    Exception in thread "main" java.lang.NullPointerException
    at SybDbms.main(SybDbms.java:26)


    import java.io.*;
    import java.sql.*;

    public class SybDbms {
    public static void main(String[] args) {
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;

    try {
    Class.forName("com.sybase.jdbc4.jdbc.SybDriver").n ewInstance();
    } catch (Exception ex) {
    // handle the error
    }
    try {
    String url = "jdbc:sybase:Tds:localhost:5003" ;
    conn =DriverManager.getConnection( url, "sa", "******" ) ;
    // Do something with the Connection
    } catch (SQLException ex) {
    // handle any errors
    System.out.println("SQLException: " + ex.getMessage());
    System.out.println("SQLState: " + ex.getSQLState());
    System.out.println("VendorError: " + ex.getErrorCode());
    }
    try {
    stmt = conn.createStatement();
    rs = stmt.executeQuery("SELECT * FROM sysobjects");
    // or alternatively, if you don't know ahead of time that
    // the query will be a SELECT...
    if (stmt.execute("SELECT * FROM sysobjects")) {
    rs = stmt.getResultSet();
    rs.first();
    System.out.println(rs.getInt(2));
    }
    // Now do something with the ResultSet ....
    }
    catch (SQLException ex){
    // handle any errors
    System.out.println("SQLException: " + ex.getMessage());
    System.out.println("SQLState: " + ex.getSQLState());
    System.out.println("VendorError: " + ex.getErrorCode());
    }
    }
    }

  2. #2
    Join Date
    Aug 2003
    Posts
    43

    Issue resolved

    I replaced the Sybase driver URL with J2SE provided generic ODBC supported databases URL and now it is working fine.
    //Class c=Class.forName("com.sybase.jdbc.SybDriver");
    Class c=Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Posting Permissions

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