0

I have been trying to connect my java login form with access database without odbc. using ucanaccess driver.

After implementing all the instructions, all I am getting is the class.forName exception first plus many other exceptions.

private void btnLoginMouseClicked(java.awt.event.MouseEvent evt) {                                      
        // TODO add your handling code here:

         try{
                Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
                String path="C:\\Users\\yamao\\Downloads\\javaJars\\ExercicesAppDb.mdb";
                String url="jdbc:ucanaccess://"+path;
                Connection con = DriverManager.getConnection(url);
                Statement st = con.createStatement();
                ResultSet rst=st.executeQuery("select * from Users");

                while(rst.next()){
                    if(rst.getString("passWord").equals(passWordTxt.getText())){
                        JOptionPane.showMessageDialog(this,"Successful Connection");
                    }
                }
            }catch(SQLException ex1){System.out.print(ex1);}
            catch(Exception ex2){}
    }     

I am expecting to have a login in light with data in my database

jpganz18
  • 5,508
  • 17
  • 66
  • 115
arnold
  • 1
  • 1
  • Please make a clear question, what is your goal with this? I assume that you want to fix it, then please provide more log information – jpganz18 Jul 25 '19 at 07:33
  • Please add the full stacktrace. – second Jul 25 '19 at 07:33
  • @jpganz18 here is the exception i am getting :Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at Login.Login.btnLoginMouseClicked(Login.java:115) at Login.Login.access$000(Login.java:19) at Login.Login$1.mouseClicked(Login.java:47) at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270) – arnold Jul 25 '19 at 07:43
  • @second please sir, i am new to java, how can do that ? – arnold Jul 25 '19 at 07:44
  • Use `ex1.printStackTrace()` and copy the result from the commandline to your question (don't put it in the commments) – second Jul 25 '19 at 07:46
  • Also check: https://stackoverflow.com/questions/26195865/ucanaccessdriver-throws-exceptionininitializererror-caused-by-java-lang-runtime – second Jul 25 '19 at 07:56
  • @second thank you, the problem has been solved – arnold Jul 25 '19 at 08:20

0 Answers0