Hi guys
I have a code that i used to connect to Ms access 2003 and 2007 in Windows Xp. It worked very fine, but it would not work in windows 7 for access 2013. Am wondering if there is a problem with the JDBC driver being supported by Windows 7.
import java.sql.*;
public class AccessConnection {
public static void main(String [] args){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String file =" C:/Users/JOSEMARIA/Documents/Progarmming/JAVA_CODES/Library";
String dbase = "jdbcdbcriver={Microsoft Access Driver (*.mdb,*.accdb)};DBQ="+file+".accdb;";
System.out.println("About to run database connection");
Connection conn = DriverManager.getConnection(dbase, "", "");
System.out.println("Database initialization and connection done");
}
catch (ClassNotFoundException | SQLException es){
System.out.println("Unable to connect to database");
es.getCause();
es.getMessage();
es.printStackTrace();
}
}
}
It gives me the errors shown below:
Unable to connect to database
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at AccessConnection.main(AccessConnection.java:21)