我做的一个Swing程序,程序里面带Access数据库,
现在想使用Java Web Start 发布,但是如果我把Access打入Jar包中,程序将无法访问Access数据库。/**
* 建立Access数据库连接
*/
public Connection getConnection() throws SQLException{
Connection conn = null;
try {
Class.forName(driver);
String realPath = getAppPath(DataSource.class);
System.out.println(realPath);
//Context.configDir 为数据库的路径,如:"c:/jswing/" 在没有打包前是这样做的。
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+ Context.configDir + "db.mdb"; conn = DriverManager.getConnection(url, user, pwd);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
throw e;
}
return conn;
}
我该如何做?
1 如果能把Access打包,该如何写?
2 如果从JWS招手解决 ,该如何做?
多谢各位帮忙??
现在想使用Java Web Start 发布,但是如果我把Access打入Jar包中,程序将无法访问Access数据库。/**
* 建立Access数据库连接
*/
public Connection getConnection() throws SQLException{
Connection conn = null;
try {
Class.forName(driver);
String realPath = getAppPath(DataSource.class);
System.out.println(realPath);
//Context.configDir 为数据库的路径,如:"c:/jswing/" 在没有打包前是这样做的。
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+ Context.configDir + "db.mdb"; conn = DriverManager.getConnection(url, user, pwd);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
throw e;
}
return conn;
}
我该如何做?
1 如果能把Access打包,该如何写?
2 如果从JWS招手解决 ,该如何做?
多谢各位帮忙??
建议数据库不要打包,通过相对路径来查找数据库文件。
把数据库打入jar包中, 当程序第一次启动时,把数据库文件导出到用户home下,即可以使用这种解决如何?
从 桌面的快捷方式启动,为什么不更新程序呢?而在网页上启动确可以更新?