我有一个javafx应用程序,以前用proguard运行良好。
但是,在将xerial-sqlite添加到我的应用程序之后,proguard仍能正常工作但是在使用 java -jar program.jar 命令运行时遇到以下错误:
18:31:42,161 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [dailyRollingFileAppender] to Logger[ROOT]
18:31:42,161 |-INFO in k.a - End of configuration.
18:31:42,161 |-INFO in j.a@44a0093e - Registering current configuration as safe fallback point
2017-Aug-13 18:31:42.287 [JavaFX Application Thread] ERROR B.c - No suitable driver found for jdbc:sqlite:merchant.db
java.sql.SQLException: No suitable driver found for jdbc:sqlite:merchant.db
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at B.e.<init>(SQLiteDataSource.java:52)
at B.e.a(SQLiteDataSource.java:61)
at com.datasoft.pay365.merchant.MainApp.start(MainApp.java:94)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:748)
实例化sqlite连接:
protected SQLiteDataSource() {
connection = null;
try {
connection = DriverManager.getConnection("jdbc:sqlite:merchant.db");
this.createTable();
} catch (SQLException e) {
logger.error(e.getLocalizedMessage());
e.printStackTrace();
}
}
我真的需要能够运行我的应用程序的sqlite版本。我该如何解决?
答案 0 :(得分:0)
您是否使用当前的类加载器加载驱动程序?
Class.forName("org.sqlite.JDBC");
如果是,您的库jar是否包含在您的java调用中或与javafx jar相同的文件夹中,或者是否可以自定义加载以供主代码访问?