Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

No Suitable Driver Found?? MySQL problem

843854Aug 22 2003 — edited Aug 29 2003
Hello All,
I am having a small problem that had grown to be a huge headache for me.

Environment ;

win2k  SP3
JAVA_HOME=C:\j2sdk1.4.1_02
MySQL version 4.0.13

Problem:

For some reason I am not being able to set the classpath to recognise the driver files for MySQL J connector;

J Conector Files I tried to use

mysql-connector-java-2.0.14-bin.jar
mysql-connector-java-3.0.8-stable-bin.jar
mysql-connector-java-3.1.0-alpha-bin.jar

Places I tried to put these files at for classpath

1. Create mySqldrivers folder in c and ut these files and set the classpath to tpoint to this folder e.g
CLASSPATH=C:\mysqlDrivers\mysql-connector-java-3.1.0-alpha-bin.jar

2. I have tried to put each of the above files in the {JAVA_HOME}\jre\leb\ext\
as well as {Program Files\Java}\jre\leb\ext\

and here is my most simple class that I am trying to test the driver with

public class TestMySQL {
  public ResultSetMetaData rsmd = null;
  public Connection conn = null;
  public Statement st = null;
  public ResultSet rs = null;
  public boolean isConnected = true;
  public TestMySQL() {
    try{
      String dbURL = "jdbc:mysql:127.0.0.1/root";
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      //org.gjt.mm.mysql.Driver
      //com.mysql.jdbc.Driver
      conn = DriverManager.getConnection(dbURL,"root","crap");
      System.out.print("Connection to root db is successfull");
    }catch(SQLException sqle){
      isConnected = false;
      System.out.println("General SQL ERROR = "+sqle.getMessage());
    }catch(Exception ie){
      isConnected = false;
      System.out.println("Class Not Found = "+ie.getMessage());
    }

  }

  public static void main(String[] args) {
    TestMySQL testMySQL1 = new TestMySQL();
  }
}

You have no idea how much I'd appreciate if some kind soul help me figure this one out.

Thanks in advance for taking time to read this.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2003
Added on Aug 22 2003
4 comments
323 views