0
我正在写一个Java程序,它需要加载本地SQLite数据库。一切工作如预期,直到我打包并在另一台计算机上尝试它。数据库查询似乎是唯一的问题。尝试返回“找不到适用于jdbc:sqlite:C:\ Data \ Test.db的合适驱动程序”。该错误使我认为它正在访问SQL类,但没有正确加载驱动程序本身。SQLite无法从Jar连接到数据库
- Windows 7的
- 中的IntelliJ编码12
- Zentus' SQLite JDBC 3.7.2
- 的Java SE 7更新25
String db_string = "C:\Data\Test.db";
try{
connection = DriverManager.getConnection("jdbc:sqlite:" + db_string);
Statement statement = connection.createStatement();
statement.setQueryTimeout(30); // 30 seconds
ResultSet rs = statement.executeQuery("select * from " + table);
while(rs.next()){
// Read the results
fileList.add(rs.getLong("modifieddate"));
}
} catch (SQLException e){
System.err.println(e.getMessage());
}
// Close the connection
finally {
try{
if(connection != null)
connection.close();
} catch (SQLException e){
System.err.println(e);
}
}
在的IntelliJ我已经通过创建一个新的神器生成JAR和指定主类。我用来读/写数据库信息的SQLite包被IntelliJ提取到Jar中。当我打开Jar时,我可以看到我的代码和SQLite代码及其JDBC驱动程序。
Manifest-Version: 1.0
Main-Class: com.myproject
我试过的其他计算机上运行的是Windows 8和Windows 7,它们都给出相同的错误。
什么可能是错的?
确实是这个问题。我曾经在另一堂课中使用过它,但在另一堂课中却忘记了。我没有意识到它超出了范围。谢谢! – Jeremy