Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Java code and connection with Ms Access 2013

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Java code and connection with Ms Access 2013

    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)
    Last edited by JOSEMARIAN; May 11th, 2014 at 03:40 PM.


Similar Threads

  1. Java MS Access not connection help please.
    By notgettingthis in forum What's Wrong With My Code?
    Replies: 9
    Last Post: March 29th, 2014, 02:34 PM
  2. how connection java app to access database that in server
    By eng.hazem in forum JDBC & Databases
    Replies: 2
    Last Post: July 29th, 2013, 06:24 AM
  3. Replies: 0
    Last Post: May 31st, 2012, 05:35 PM
  4. MS Access database connection problem
    By faysal40 in forum JDBC & Databases
    Replies: 1
    Last Post: August 29th, 2011, 01:22 AM
  5. [SOLVED] I have a problem with this java code for database access
    By abhiM in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 19th, 2011, 03:52 AM