0
我爲我的項目使用netbeans,並將我的key.db模式文件存儲在src文件夾中。 (在哪裏使用SQLite的概念)程序工作正常時,從淨豆執行。但在執行jarfile時會顯示以下異常。如何在jar文件中訪問.db模式文件
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)
請幫忙解決這個問題,excuss如果問題太荒謬了
請回答我的問題。等待過去19小時的解決方案 – prathima
沒有人知道如何回答我的問題,儘管這並不荒唐。這是無用的網站 – prathima