【发布时间】:2013-01-17 19:07:17
【问题描述】:
我有一个访问数据库,我正在用 Java 编程。 我可以用什么来连接我的 netbeans 和我在 localhost 上的数据库?
仅在 Windows 中找到此代码(它使用本地 db 文件):
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver " +
"(*.mdb, *.accdb)};DBQ=C:\\Database\\Northwind 2007.accdb";
Connection con = DriverManager.getConnection(url);
System.out.println("Connected!");
con.close();
} catch (SQLException e) {
System.out.println("SQL Exception: "+ e.toString());
} catch (ClassNotFoundException cE) {
System.out.println("Class Not Found Exception: "+cE.toString());
}
也许有人知道如何为 mac 环境修改它?
【问题讨论】:
标签: java macos ms-access netbeans