我做的一个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招手解决 ,该如何做?
多谢各位帮忙??
不过你这种jdbc的使用,我还真的不清楚怎么用。
如果不行 ,我只有采用access 后下载了!!!!