Background:
Java > Maven Jar Project
function is to record the number of keystrokes per day for the user
Using the Jar2exe tool to convert a jar to an EXE executable file
The MySQL database used in the original project, using the MyBatis tool to operate without problems
Later found for a gadget, using MySQL too cumbersome, because the need to install configuration MySQL and so on.
So I went online to check, found a lightweight embedded database SQLite
Import a org.xerial > Sqlite-jdbc jar Package and it's easy to create a database file directly
The jar that was used was the latest version 3.20.0
A day of effort to replace the previous persistence layer code from MySQL to SQLite
Problem Description:
Works well inside the editor
After compiling into jar, use Java-jar ***.jar to run well
When I turn the jar with Jar2exe to EXE file, it's an error.
The error message is as follows:
Java.sql.SQLException:Error opening Connectionat Org.sqlite.core.CoreConnection.open (coreconnection.java:215) at Org.sqlite.core.coreconnection.<init> (coreconnection.java:76) at Org.sqlite.jdbc3.jdbc3connection.<init > (jdbc3connection.java:26) at org.sqlite.jdbc4.jdbc4connection.<init> (jdbc4connection.java:24) at Org.sqlite.sqliteconnection.<init> (sqliteconnection.java:45) at Org.sqlite.JDBC.createConnection (Jdbc.java : Org.sqlite.JDBC.connect (jdbc.java:88) at Com.mchange.v2.c3p0.DriverManagerDataSource.getConnection ( drivermanagerdatasource.java:119) at Com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection ( wrapperconnectionpooldatasource.java:143) at Com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection (Wrapperconnectionpooldatasource.java :) at Com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.initializeAutomaticTestTable ( c3p0pooledconnectionpoolmanager.java:772) at Com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager. Createpooledconnectionpool (c3p0pooledconnectionpoolmanager.java:696) at Com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.getPool (c3p0pooledconnectionpoolmanager.java:257) at Com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager.getPool (c3p0pooledconnectionpoolmanager.java:271) at Com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection (abstractpoolbackeddatasource.java:128) at Com.play.util.SQLiteUtil.openConnection (sqliteutil.java:56) at Com.play.base.BaseDaoImpl.execute ( basedaoimpl.java:54) at Com.play.dao.impl.KeyRecordDayDaoImpl.add (keyrecorddaydaoimpl.java:22) at Com.play.DataManager.addToDayRecord (datamanager.java:75) at Com.play.DataManager.addBeat (datamanager.java:58) at Com.play.datamanager.lambda$new$0 (datamanager.java:32) at Java.lang.Thread.run (thread.java:748) caused by: Java.lang.NullPointerExceptionat org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary (sqlitejdbcloader.java:315) At Org.sqlite.SQLiteJDBCLoader.initialize (sqlitejdbcloader.java:64) at org.sqlite.cOre. Nativedb.load (nativedb.java:56) at Org.sqlite.core.CoreConnection.open (coreconnection.java:211) ... More
Very nerve-racking, on-line search for a long while did not find the relevant issues
Eventually FQ to Google to search for some
Found a similar problem, all in English, specifically did not read too understand
But it mentions the issue of the Sqlite-jdbc jar version.
So I'm holding on to a try mentality
Changed the version to 3.8.11.2
Compile complete > Turn EXE finish > Run successfully > Problem solving!
Problems with a Java project that cannot be started after using the SQLite database