简体   繁体   中英

Java Desktop app with Ms Access

My Db connection is error " class not found exception !". I want to show in java jTable with query result..

static Connection databaseConnection()throws ClassNotFoundException{
        Connection con=null;
        File file=new File("PlayDb/PlayIS.mdb");
        try{
            Class.forName("sun.jdbc.odbc.jdbcodbcDriver");
            con =DriverManager.getConnection("jdbc:odbc:Driver="+"{Microsoft Access Driver(*.mdb,*.accdb)};DBQ="+file.getAbsoluteFile());
            System.out.print("Success con!!");
        }
        catch(Exception e){
            System.out.print("connection fail!!");
        e.printStackTrace();
        }
        return con;
   }

If you can post full stacktrace, that would be easy to answer your question. According to the description ( "class not found exception!" ) it looks like JVM can't load your JDBC driver.

Please post full stacktrace.

Did you set up "Data Source Name" correctly ?

Following tutorial how to how to setup "Data Source Name " and how to connect Java and MS Access database. An Overview of Java Database Connectivity

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM