Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7015109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:36:34+00:00 2026-05-27T22:36:34+00:00

This question has been asked a lot here, but i still can’t fix my

  • 0

This question has been asked a lot here, but i still can’t fix my problem:
I put mysql-connector-java-5.1.18-bin into C:\Program Files\Java\jre6\lib\ext folder.
I have this code:

    // Load the database driver
    Class.forName("com.mysql.jdbc.Driver");
    // Get a connection to the database
    Connection conn = DriverManager.getConnection(
                        "jdbc:mysql://localhost:3306/mysql", "root", "4958ps");
    // Get a statement from the connection
    Statement stmt = conn.createStatement() ;
    // Execute the query
    ResultSet rs = stmt.executeQuery( "SELECT * FROM Cust" ) ;
    // Loop through the result set
    while( rs.next() )
        System.out.println( rs.getString(1) ) ;
    // Close the result set, statement and the connection
    rs.close() ;
    stmt.close() ;
    conn.close() ;
} catch( SQLException se ) {
    System.out.println( "SQL Exception:" ) ;
    // Loop through the SQL Exceptions
    while( se != null ) {
        System.out.println( "State  : " + se.getSQLState()  ) ;
        System.out.println( "Message: " + se.getMessage()   ) ;
        System.out.println( "Error  : " + se.getErrorCode() ) ;
        se = se.getNextException() ;
    }          
} catch( Exception e ) {
    e.printStackTrace();
} 

and i get a ClassNotFoundException with the following stack trace:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at pack.Test.main(Test.java:14)

I also changed CLASSPATH variable to be C:\Program Files\Java\jre6\lib\ext\mysql-connector-java-5.1.18-bin
Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:36:35+00:00Added an answer on May 27, 2026 at 10:36 pm

    The zip you downloaded should contain a file named mysql-connector-java-5.0.8-bin.jar or similar. Version might be different. Check that it is present and check that it is directly in your classpath (not in a subdirectory etc.).

    If that’s alright, check that your classpath variable is not overwritten by something else. If you execute your program manually do it like this: java -cp "C:\Program Files\Java\jre6\lib\ext\mysql-connector-java-5.0.8-bin.jar:." YourClass

    If you are using an IDE such as eclipse, check your build-path settings there. (In eclipse you would right click your project -> Properties -> Java Build Path -> Add external JARs and then supply the path of your connector…jar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this question has been asked a lot, but I still can't understand how
This question has been asked before perhaps multiple times, but I can't get the
I know this question has been asked before, but I ran into a problem.
I know this sort of question has been asked before , but I still
I know this question has been asked several times, but I can't quite seem
I guess this question has been asked a lot around. I know Rails can
I'm sure this question has been asked many times, but I can't figure this
I'm sorry if this question has been asked before, but I can't seem to
I know this question has been asked a lot, but not yet to my
This question has been asked here in one form or another but not quite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.