Results 1 to 6 of 6

Thread: SQLException

  1. #1
    Join Date
    Sep 2003
    Posts
    4

    Unhappy Unanswered: SQLException

    Hi,

    I am new to the usage of mysql with java. I'm using mysqlconnector/j to make the connection and I'm trying to access to the database of mysql from java. My code looks like the following:

    try{
    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    Connection conn= DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=xxx");

    }catch (Exception ex){
    System.out.println("SQLException:"+ex.getMessage() );
    }

    The .jar file is added in autoexec.bat (mysql-connector-java-3.0.8-stable-bin.jar).
    Everything compiles but when I try to execute I get this:

    SQLException: com.mysql.jdbc.Driver

    I don't know where is the problem. Any help?????? It's very important. Thank you,
    Maite

  2. #2
    Join Date
    Jan 2003
    Location
    Paris, France
    Posts
    320
    Could you please the comple error message
    Olivier Miossec
    --
    http://www.lasso-developpeur.net/
    --

  3. #3
    Join Date
    Sep 2003
    Location
    POLAND/WARSAW/ZIELONKA
    Posts
    5
    try this instead:
    Class.forName( DRIVER_NAME );

    of course try putting source files of mysql connector into your classpath. I've had similar problems but it works fine now. However i still do not know why it didn't want to work with *.jar. Anyone knows the answer?

  4. #4
    Join Date
    Sep 2003
    Posts
    4

    java+mysql

    Originally posted by mgrula
    try this instead:
    Class.forName( DRIVER_NAME );

    of course try putting source files of mysql connector into your classpath. I've had similar problems but it works fine now. However i still do not know why it didn't want to work with *.jar. Anyone knows the answer?


    I have: Class.forName("com.mysl.jdbc.Driver"), but it doesn't go well. I have put the .jar file of mysqlconnector/j in the classpath and the error I get when I execute is: SQLException: com.mysql.jdbc.Driver

  5. #5
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1

    Classpath

    Hi
    But how do we set the classpath in Sun One Studio 5?

    Im also have the same error trying to connect to mysql in this IDE

    Thanks

  6. #6
    Join Date
    Sep 2003
    Location
    POLAND/WARSAW/ZIELONKA
    Posts
    5
    ok guys, here's the answer. Try this:

    D:\archiwum\wersja 1.0.9>
    java -classpath .;mysql-connector-java-.0.8-stable-bin.jar MyMainCLASS

    it works fine. I just added manually all necessary paths: "." and "mysql-connector-java-.0.8-stable-bin.jar ".

    However if I put it that way:
    java -classpath .;*.jar MyMainCLASS

    it fails

Posting Permissions

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