我正在为我的项目使用 netbeans,并将我的 key.db 模式文件存储在 src 文件夹中。(使用 SQLite 概念)程序在从 net beans 执行时工作正常。但是在执行 jarfile 时显示以下异常。
String sDriverName = "org.sqlite.JDBC";
Class.forName(sDriverName);
try {
URL url = insert.class.getResource("key.db");
String sTempDb = url.getPath();
System.out.println(sTempDb);
String sJdbc = "jdbc:sqlite";
String sDbUrl = sJdbc + ":" + sTempDb;
int iTimeout = 30;
Connection conn = DriverManager.getConnection(sDbUrl);
Statement stmt = conn.createStatement();
stmt.setQueryTimeout(iTimeout);
System.out.println(GetBoard.number());
ResultSet rs=stmt.executeQuery("select count(id) from list");
if(rs.next()){
if(rs.getInt(1)>1){
ResultSet mbtest=stmt.executeQuery("select motherboard from list where motherboard='"+GetBoard.number()+"'");
if(mbtest.next())
;//okay
else
JOptionPane.showMessageDialog(null, "This version of Smart eDocT Software is not original. "
+ "\n please contact sicsi to getFull version.");
}
else{
int idv;
ResultSet getid=stmt.executeQuery("select max(id) from list");
if(getid.next()){
idv=getid.getInt(1)+1;
}
else{
idv=1;
}
stmt.executeUpdate("insert into list values("+idv+",'"+GetBoard.number()+"')");
}
}
rs.close();
stmt.close();
conn.close();}
例外是:
java.sql.SQLException: path to 'file:/D:/security/store/SCHEDULAR.jar!/key.db': 'C:\\file:' does not exist
at org.sqlite.Conn.open(Conn.java:103)
at org.sqlite.Conn.<init>(Conn.java:57)
at org.sqlite.JDBC.createConnection(JDBC.java:77)
at org.sqlite.JDBC.connect(JDBC.java:64)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at insert.main(insert.java:26)
请帮助解决这个问题,如果问题很荒谬,请原谅