如何将 java 连接到 Ms Access 2010? [英] How to connect java to Ms Access 2010?
本文介绍了如何将 java 连接到 Ms Access 2010?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人知道如何将 Access 2010 连接到 java jdbc.我使用这个方法,但是当我调用它时,它不起作用:
Does anyone have any ideas of how to connect Access 2010 to java jdbc. I use this method, but when I call it, it doesn't work:
public void loadDb(){
try{
Class.forName("sun.jdbc.JdbcOdbcDriver");
File f = new File(System.getProperty("user.dir"))
con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Acess Driver (*.mdb, *.accdb)}; DBQ="+ f.getPath() + "//db//JavaAccess.accd","","");
st = con. createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
}catch(ClassNotFoundException e){e.printStackTrace();
}catch(SQLException e){e.printStackTrace();}
}
//con and st are already defined
推荐答案
根据 msdn 应该是sun.jdbc.odbc.JdbcOdbcDriver
.所以替换这行代码:
According to msdn it should be sun.jdbc.odbc.JdbcOdbcDriver
. So replace this line of code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
这篇关于如何将 java 连接到 Ms Access 2010?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文