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
精彩评论