0

I am trying to connect java fx with ms access.... I have used java fx with netbeans 8.2 to connect with microsoft access 2016 this is the program that I have wrote:

       " String s1,s2;
s1=jTextField1.getText();
s2=jTextField2.getText();
try{
    Connection conn=DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\dalya\\Documents\\Test1.accdb");
    Statement st= conn.createStatement();
    int a= st.executeUpdate("insert into Test1 values ('"+s1+"', '"+s2+"')");
    if (a==1){
        jLabel3.setText("Record Inserted");
    }
    else {
        jLabel3.setText("Record not Inserted");
    }


}catch (Exception e){
    //e.printStackTrace();
    System.out.println("Error in Connection");
}"

I have added five jar files, these files are: A. hsqldb.jar B. jackcess-2.1.9.jar C. ucanaccess-4.0.3.jar D. Commons-lang-3-3.7.0.jar E. Commons-logging-1.2.0.jar

But... I have got an error with jar files common-lang which I have already downloaded ... this is the Error that I have got:

"Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/lang/builder/CompareToBuilder
    at com.healthmarketscience.jackcess.impl.RowIdImpl.compareTo(RowIdImpl.java:106)
    at com.healthmarketscience.jackcess.impl.IndexData$Entry.compareTo(IndexData.java:2169)
    at com.healthmarketscience.jackcess.impl.IndexData$Entry.compareTo(IndexData.java:1977)
    at java.util.Collections.indexedBinarySearch(Collections.java:226)
    at java.util.Collections.binarySearch(Collections.java:213)
    at com.healthmarketscience.jackcess.impl.IndexData$DataPage.findEntry(IndexData.java:2700)
    at com.healthmarketscience.jackcess.impl.IndexData.findEntryPosition(IndexData.java:889)
    at com.healthmarketscience.jackcess.impl.IndexData.access$3700(IndexData.java:47)
    at com.healthmarketscience.jackcess.impl.IndexData$EntryCursor.updatePosition(IndexData.java:2465)
    at com.healthmarketscience.jackcess.impl.IndexData$EntryCursor.restorePosition(IndexData.java:2403)
    at com.healthmarketscience.jackcess.impl.IndexData$EntryCursor.restorePosition(IndexData.java:2386)
    at com.healthmarketscience.jackcess.impl.IndexData$EntryCursor.beforeEntry(IndexData.java:2348)
    at com.healthmarketscience.jackcess.impl.IndexCursorImpl.findPotentialRow(IndexCursorImpl.java:369)
    at com.healthmarketscience.jackcess.impl.IndexCursorImpl.findFirstRowByEntryImpl(IndexCursorImpl.java:280)
    at com.healthmarketscience.jackcess.impl.IndexCursorImpl.findFirstRowByEntry(IndexCursorImpl.java:152)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl$DefaultTableFinder.findRow(DatabaseImpl.java:2296)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl$TableFinder.findObjectId(DatabaseImpl.java:2175)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.readSystemCatalog(DatabaseImpl.java:878)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.<init>(DatabaseImpl.java:533)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.open(DatabaseImpl.java:400)
    at com.healthmarketscience.jackcess.DatabaseBuilder.open(DatabaseBuilder.java:252)
    at net.ucanaccess.jdbc.DefaultJackcessOpener.open(DefaultJackcessOpener.java:32)
    at net.ucanaccess.jdbc.DBReference.<init>(DBReference.java:169)
    at net.ucanaccess.jdbc.DBReferenceSingleton.loadReference(DBReferenceSingleton.java:51)
    at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:91)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:270)
    at NewJFrame.jButton1ActionPerformed(NewJFrame.java:107)
    at NewJFrame.access$000(NewJFrame.java:12)
    at NewJFrame$1.actionPerformed(NewJFrame.java:50)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6533)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6298)
    at java.awt.Container.processEvent(Container.java:2236)
    at java.awt.Component.dispatchEventImpl(Component.java:4889)
    at java.awt.Container.dispatchEventImpl(Container.java:2294)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    at java.awt.Container.dispatchEventImpl(Container.java:2280)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4711)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.builder.CompareToBuilder
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 66 more"
fabian
  • 80,457
  • 12
  • 86
  • 114
  • You say you have a `JavaFX` app but your error message hint to your `nodes` being `awt` and `swing`. Did you import the right nodes? – SedJ601 Jan 04 '18 at 22:06
  • With the 'ucanaccess` stuff, you have to make sure you are using all the support libraries, and that your versions of the different `Jars` work together. – SedJ601 Jan 04 '18 at 22:10
  • I just import the jar files,,, and the uacnaccess and all other jars,, I downloaded the last version of them..... how can I solve the problem of duplication ??? – user9174932 Jan 04 '18 at 22:19

0 Answers0