android - Where to find or download USB Driver folder?
Driver on

How to solve java.lang.ClassNotFoundException:

I’ve written this java software to reply the information from the command line and retailer it right into a database :

 import java.util.Scanner;
import java.sql.*;


public class Program {


    public static void predominant(String[] args)throws ClassNotFoundException 


    {


        Connection conn=null;

        strive {

            Class.forName("com.mysql.jdbc.Driver");

             conn = DriverManager.getConnection("jdbc:mysql://localhost/DevOps_DB","root","root");


             PreparedStatement st = conn.prepareStatement("INSERT INTO pers " + "VALUES ('"+args[0]+"'); ");
             st.executeUpdate();


        } 



        catch (SQLException ex) {

            System.out.println("SQL Exception : "+ ex.getMessage());

            System.out.println("Vendor Error : "+ ex.getErrorCode());

        }


        catch(ClassNotFoundException ex) {

            ex.printStackTrace();


        }



//      
//      for(String arg : args)            
//      {   
//           System.out.println(arg);            
//      }




    }





}

However I’ve received the next exception :

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.internet.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.safety.AccessController.doPrivileged(Native Technique)
    at java.internet.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
    at solar.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
    at java.lang.Class.forName0(Native Technique)
    at java.lang.Class.forName(Class.java:190)
    at Program.predominant(Program.java:18)

why ? … any assist to repair the issue ?

EDIT :

I added the .jar file , see the next picture :

enter image description here

Leave a Reply

Your email address will not be published. Required fields are marked *