Sir in Netbeans when I run program it runs successfully but when I make jar file and run it then there is this error :
java.lana.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
Please answer me that how to solve that exception.
Here is my code:
public class DatabaseManager {
static Connection con;
static{
System.out.println("Connecting To Database ... ... ...");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:Pepsi");
} catch (ClassNotFoundException | SQLException ex) {
JOptionPane.showMessageDialog(null, ex);
System.exit(0);
Logger.getLogger(DatabaseManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
I have also used ucanaccess me libariers for direct access to database.
con = DriverManager.getConnection("jdbc:ucanaccess:C:\\Users\\Administrator\\Documents\\NetBeansProjects\\Pepsi\\Pepsi.accdb");
When I ran java while the exception comes but in Netbeans it works properly.