1

The JDBC-ODBC Bridge is no longer included in Java 8 so I tried UCanAccess, but I am having trouble with that. Here is my code:

  package jdbc;
  import java.sql.*;

 public class jdbc  
 {
    Connection con;
    Statement st;

    jdbc()
    {  
        try
        {
            con=DriverManager.getConnection("jdbc:ucanaccess://P:/eclipseWorkspace/databases/signup.accdb");
        st=con.createStatement();

        st.executeUpdate("INSERT INTO signup (firstName,lastName,email,password)     VALUES ('rocky','balboa','rocky@gmail.com','pop')");
        System.out.println("SUCCESS");

    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    }


}

class main
{
     public static void main(String args[])
    {
        new jdbc();
    }
}

I have included some external jars as shown in the image:

http://i.imgur.com/ujhPP0l.png?1

When i run it, it gives me a stack trace with ClassNotFoundException and NoClassDefFound errors as shown here:

http://i.imgur.com/UACP77k.png?1

What is wrong with my code?

Community
  • 1
  • 1
  • Please mention the loads of errors that you are receiving! – ρss May 23 '14 at 20:26
  • [Class.forName](http://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) is not longer supported? The documentation say something other. – Jens May 23 '14 at 20:27
  • errors are shown in the image link (the last one). –  May 23 '14 at 20:29
  • When you unzipped the UCanAccess distribution it created a `lib/` folder with the compatible versions of the required dependencies. One of those is `commons-lang-2.6.jar` but I see from your screenshot that you are using `commons-lang3-3.3.2.jar`. Try replacing that one with the 2.6 version in the UCanAccess `lib/` folder and see if that helps. – Gord Thompson May 23 '14 at 21:12
  • @Gord i did as you said. And now i have new errors. net.ucanaccess.jdbc.UcanaccessSQLException: user lacks privilege or object not found: SIGNUP Old ones were fixed , so thanks for that. –  May 24 '14 at 06:53
  • All fixed guys. Thanks everyone. –  May 24 '14 at 07:39

1 Answers1

1

UCanAccess has several dependencies, one of which is commons-lang-2.x (2.4 or newer). You are using commons-lang3-3.3.2 in your project, so UCanAccess (actually Jackcess) cannot find the commons-lang-2.x classes.

When you unzipped the UCanAccess distribution it created a lib/ folder with the compatible versions of the required dependencies. You need to replace the commons-lang3-3.3.2.jar reference in your project with commons-lang-2.6.jar from the UCanAccess lib/ folder.

Gord Thompson
  • 98,607
  • 26
  • 164
  • 342