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

  • Home
  • SEARCH
  • 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 7000987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:44:40+00:00 2026-05-27T20:44:40+00:00

Can any one help me how to run this code… If I compile this

  • 0

Can any one help me how to run this code…

If I compile this code it complies successfully, But when I run class file throws

This is the stack trace for that exception :

Exception: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    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:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at ExportData.main(ExportData.java:13)

Here is the code :

import java.io.*; 
import java.sql.*;

public class SampleMysql {
    public static void main(String args[]) {
        String Driver;
        Statement stmt; 
        ResultSet rs; 
        Driver = "com.mysql.jdbc.Driver";
        Connection con = null;

        try {
            Class.forName(Driver);
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/TempAttendance","root", password); 

            if(!con.isClosed()){

                System.out.println("Successfully connected to MySQL DataBase \n");
                stmt = con.createStatement(); 
                String tablename = "Employee_Master";
                String sql;

                rs = stmt.executeQuery("select * from Employee_Master");

                while(rs.next()) {
                    System.out.print(rs.getString("Name"));
                }
            }
        } catch(Exception e) {
            System.err.println("Exception: " + e.getMessage());
        }  finally {
            try {
                if(con != null)
                    con.close();
            } catch(SQLException e) {
            }
        }
    }
}
  • 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-27T20:44:41+00:00Added an answer on May 27, 2026 at 8:44 pm

    You should download and place your driver jar (mysql jar) file in your class path

    Documentation

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

Sidebar

Related Questions

Can any one help me. I have this ‘unmanaged’ .NET code, which works on
Can any one help me convert the below code to LINQ? Select Catg,Count(*) From
can any one help me with code that subtract 1 from a digit stored
Can any one of you help me in converting an windows dll file in
can any one help me in creating a regular expression for password validation. The
Can any one help me how to sort rows by relevance for the following
I am new in Pocket PC and Smart phone. so can any one help
Apologies I can't post any code at this time cos I'm away from my
I wonder if any of you could help with this problem. The following code
Can anyone help with with the time complexity of this algorithm, and why it

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.