Results 1 to 8 of 8
  1. #1
    islan is offline Member
    Join Date
    Jul 2009
    Posts
    3
    Rep Power
    0

    Default Problems with MySQL Driver

    I have never done remote logins in Java before, so I am very new to this.

    I copied this test code from MySQL 5.0:
    Java Code:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    
    // Notice, do not import com.mysql.jdbc.*
    // or you will have problems!
    
    public class LoadDriver {
        public static void main(String[] args) {
            try {
                // The newInstance() call is a work around for some
                // broken Java implementations
    
                Class.forName("com.mysql.jdbc.Driver").newInstance();
            } catch (Exception ex) {
                // handle the error
            }
        }
    }
    I ran it and it worked fine, so I thought I could continue with my own code. When nothing worked however, I went back and added a System.out.prinlnt("Exception: " + ex.getMessage()); to the catch statement.

    When I ran the code this time, I got this message:

    Exception: com.mysql.jdbc.Driver

    I have no idea what this means and Google for once is not helping me at all.

    Thanks for your time.

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

  3. #3
    islan is offline Member
    Join Date
    Jul 2009
    Posts
    3
    Rep Power
    0

    Default

    I've read in three different places about adding the driver (Connector/J I think it's usually called online) to the classpath, but none of the instructions worked. If I recall, one was just typing out a long command in the terminal starting with Classpath, ending in the downloaded driver. The second one was adding the Classpath command to /etc/environment (which I later removed when it interfered with running normal java programs), the third was performing a jar command.

    I don't know if I did it right, but I did it exactly as the instructions all read.

  4. #4
    islan is offline Member
    Join Date
    Jul 2009
    Posts
    3
    Rep Power
    0

    Default

    So can anyone give me any info on how to properly install this driver? None of the documentation thus far has been of any help.

  5. #5
    Join Date
    Jul 2009
    Posts
    10
    Rep Power
    0

    Default

    have you include the MySQL Connector (jar file)?
    i found this when trying to execute code without MySQL Connector:
    com.mysql.jdbc.Driver

  6. #6
    mityay is offline Member
    Join Date
    Jun 2009
    Posts
    8
    Rep Power
    0

    Default

    I'm having the same exact issue. I couldn't find MySQL connector jar file anywhere (I have mysql 5.0.75 installed). Please let me know the exact name of MySQL connector jar file. Where exactly it has to be included?
    Thank you

  7. #7
    Join Date
    Jul 2009
    Posts
    10
    Rep Power
    0

    Default

    you may get the jar file dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.8.zip/from/pick, i think it must be more comfortable if we use Netbeans IDE in developing application. for adding the jar file by doing these:
    1. right click on the project,
    2. select Properties,
    3. select Libraries,
    4. click Add Jar/ Folder,
    5. select the jar file,
    6. ok
    try to rebuild the project then run it.

  8. #8
    mityay is offline Member
    Join Date
    Jun 2009
    Posts
    8
    Rep Power
    0

    Default

    Thanks, mariosimaremare! That worked perfectly

    The new issue I now experience when I use getGeneratedKeys() method on Statement object. "java.sql.SQLFeatureNotSupportedException" exception is thrown. Is this an issue of mysql driver that does not have this method defined?

    thanks
    Last edited by mityay; 08-07-2009 at 05:25 AM.

Similar Threads

  1. Replies: 4
    Last Post: 03-31-2010, 12:08 PM
  2. hello the community & mysql connecting problems
    By scchia in forum New To Java
    Replies: 6
    Last Post: 07-16-2008, 08:49 AM
  3. Replies: 0
    Last Post: 04-22-2008, 11:57 AM
  4. can't register a MySQL driver
    By prfalco in forum New To Java
    Replies: 4
    Last Post: 02-03-2008, 11:13 PM
  5. mysql driver problem
    By mokingsu in forum JDBC
    Replies: 4
    Last Post: 01-17-2008, 05:27 PM

Tags for this Thread

Posting Permissions

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