2
votes

I'm trying to make a connection to sqlite from netbeans but it doesn't get my conexion class

this is my code:

   package Petrocabimas_App;

import Petrocabimas_app.Login;

import java.sql.*;

import javax.swing.*;

public class Conexion {


 Connection conn= null;
  public static void main(String args[]) {
 Login log= new Login();
log.setVisible (true);
}

public static Connection ConnecrDb(){


try{
Class.forName("org.sqlite.JDBC");
 Connection conn =DriverManager.getConnection("jdbc:sqlite:F:/Petrocabimas/APLICACIÓN AVISO CAMBIO/Petrocabimas_App/Petrocabimas.db");
System.out.println( "Connection Established");
return conn;
   }catch (Exception e){
       JOptionPane.showMessageDialog(null, e);
   return null;

   }

}
}

And this is my error:

java.lang.NoClassDefFoundError: Petrocabimas_app/Conexion (wrong name: Petrocabimas_App/Conexion) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) 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) Could not find the main class: Petrocabimas_app.Conexion. Program will exit. Exception in thread "main" Exception in thread "main" Java Result: 1

1
Check your package declaration. Specifically, should "App" really be upper-case?dnault

1 Answers

2
votes

at logs

java.lang.NoClassDefFoundError: Petrocabimas_app/Conexion 

but

package Petrocabimas_App;

update class path at place where your call Connexion class