简体   繁体   中英

NullPointerException source not found

I have already posted the same problem twice with two different questions since according to the comments it was not clear enough or moreover complete in terms of information so I modified the first one and here it is.

My application works well in netbeans, it does not report any errors. but after creating an installer (with launch4j and innoSetup), the application reports a NullPointerException whose source I don't know. need help please. Thank you

Here is a snippet of my code:

import java.awt.HeadlessException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;


public class Login extends javax.swing.JFrame {
    Connecteur connexion = new Connecteur();
    Statement stm;
    ResultSet resultat;
    public static String Id ="";
    
    public Login() {
        initComponents();
    }

   
                          

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        
        
        try {
   (here)stm =connexion.obtenirconnexion().createStatement();
            System.out.println(stm);
            ResultSet resultat = stm.executeQuery("select * from Techniciens where UserName ='"+UserName.getText().toString()+"'");
            
            Id = resultat.getString("IdTech");
            
            if ((resultat.getString("UserName").equals(UserName.getText().toString())) && (resultat.getString("Password").equals(Password.getText().toString()))){
            
            Principale P = new Principale();
            P.setVisible(true);
            this.hide();
            }
   
            
        } catch (HeadlessException | SQLException e) {
            JOptionPane.showMessageDialog(null, "Compte invalide");
            
        }
        finally{
            try{
                stm.close();
            }catch(Exception e){
                JOptionPane.showMessageDialog(null, e);
            }
        } 

        
    }

class conneteur:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class Connecteur {
    Connection con ;
    public Connecteur(){
        try{
            
          Class.forName("org.sqlite.JDBC");
        }catch(ClassNotFoundException e){
           System.err.println(e);
          //message d'erreur
        }
        try{
          con = DriverManager.getConnection("jdbc:sqlite:C:\\DataBase\\IPM.db");
            System.out.println("connected");
            
        }catch(SQLException e){
            System.err.println(e);
            
        }
    }
    Connection obtenirconnexion(){return con;}
}

exception:

Microsoft Windows [Version 10.0.19042.1288]
    (c) Microsoft Corporation. All rights reserved.

    C:\Users\Zouzou>cd desktop

    C:\Users\Zouzou\Desktop>java -jar "Logiciel_IPM.jar"
    java.lang.ClassNotFoundException: org.sqlite.JDBC
    java.sql.SQLException: No suitable driver found for jdbc:sqlite:C:\DataBase\IPM.db
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at logiciel_ipm.Login.jButton1ActionPerformed(Login.java:98)
        at logiciel_ipm.Login.access$000(Login.java:11)
        at logiciel_ipm.Login$1.actionPerformed(Login.java:49)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown 
        Source)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown 
        Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown 
        Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.ClassNotFoundException: org.sqlite.JDBC
    java.sql.SQLException: No suitable driver found for jdbc:sqlite:C:\DataBase\IPM.db

You didn't package the jdbc driver you use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM