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 4237782
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:49:07+00:00 2026-05-21T02:49:07+00:00

I am trying to use an external mysql database in my java application, but

  • 0

I am trying to use an external mysql database in my java application, but I keep getting java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
when the application tries to make a connection.

This is the code I use to open the connection.
What is causing this?

// Post: A connection is opened if the current connection is not valid
    private static boolean open() throws SQLException {
        // If connection is still valid, return without doing anything
        try {
            if (connection != null && connection.isValid(1)) {
                return true;
            }
        }
        catch (SQLException e1) {
            close();
        }

        // Start connecting
        String driver   = "com.mysql.jdbc.Driver";
        String url      = "jdbc:mysql://mysql.starredout.com/" + database;
        String user     = "starredout";     
        String password = "starredout";
        try {
            Class.forName(driver).newInstance();
        }
        catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        connection  = DriverManager.getConnection(url,user,password);
        return true;
    }

    // Post: If a connection was open, it is closed
    private static void close() {
        try {
            if (connection == null || connection.isClosed())
                return;
            connection.close();
        }
        catch (Exception e) {
            e.printStackTrace();
            System.out.println(e.toString());
        }   
    }
  • 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-21T02:49:08+00:00Added an answer on May 21, 2026 at 2:49 am

    That error means that it couldnt find the class you tried to make it run.
    This is probably caused because you forgot to link the driver library to your build path?
    The library is probably stored in a .jar file, so you have to mention that jar in your classpath.

    In case you use eclipse just right click your project ==> Build path ==> configure build path, then click the Libraries tab, and click Add JARs… and select the jar you wish to include in the classpath
    In other IDE’s it should be a similar process

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

Sidebar

Related Questions

I am trying to use the HDBC MySQL driver in my project. I seem
I have Visual 2010, I am trying to generate dal from my database. I
I've done a fair bit of mysql php programming but am pretty new to
I am trying to plan out a few iOS/server apps for internal use. On
When am trying to set default date and default sysdate am getting following errors:
I've been doing PHP/MySQL websites with shared hosting providers for the last couple years.
I have an external HTML source that I want to scrape and either transform
I am having a problem in my php. What I'm trying to do here
I've just started playing with Google App Engine using php via Quercus. I'm not
I seem to go back and forth on this, sometimes it works for me,

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.