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());
}
}
}
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());
}
}
}