I am trying to connect to an existing Access database using UCanAccess from NetBeans IDE 8.2 but am getting an error I can't figure out...
This is the code at this time (pStrFile is the full path to an existing Access file):
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
String database = "jdbc:ucanaccess:" + pStrFile;
Connection conn = DriverManager.getConnection(database);
conn.close();
} catch (Exception ex) {
ex.printStackTrace();
}
This is stack trace I'm getting...
java.lang.ClassNotFoundException: net.ucanaccess.jdbc.UcanaccessDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at DevGSLibData01.DevGSLibData01.DoConnect(DevGSLibData01.java:28)
at DevGSLibData01.DevGSLibData01.main(DevGSLibData01.java:18)
I have also added all the required libraries in the UCanAccess package:
Despite being listed in the Libraries of the NetBeans project, "ucanaccess-4.0.1.jar" was not found in the build path (classpath) when the application was launched. Removing "ucanaccess-4.0.1.jar" from the project Libraries and re-adding it seems to have solved the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.