I'm running Sqlite on windows 7 and using a java program from within Eclipse, to attempt to load data from an input file, into a sqlite database table. The sqlite exe file, the java sqlite JDBC jar file and the database file are all in the same directory.
I've read most of the threads which sound like they were close to answering this problem but not solved so far.
I've changed the folder permissions so anybody/everybody has update/change access to the folder(where the db file is), but still no joy. I have established a database connection (see display below) but am now stuck and I've run out of ideas - can anybody help? The code fails on Line 30
public class Database {
public void loadPersonData() {
Connection connection = null;
PreparedStatement preparedStatement = null;
try {
connection = ConnectionConfig.getConnection();
preparedStatement = connection
.prepareStatement("INSERT INTO PERSON(PERSON_ID,LAST_NAME,FIRST_NAME,STREET,CITY) "
+ "VALUES(?,?,?,?,?)");
for (PersonData x : ReadPersonData.personList) {
preparedStatement.setInt(1, x.getPersonID());
preparedStatement.setString(2, x.getLastName());
preparedStatement.setString(3, x.getFirstName());
preparedStatement.setString(4, x.getStreet());
preparedStatement.setString(5, x.getCity());
preparedStatement.addBatch();
}
THIS IS LINE 30 ->>>>> preparedStatement.executeBatch();
} catch (Exception e) {
e.printStackTrace();
Currently the error messages are as below :-
database connection established
java.sql.SQLException: unable to open database file
at org.sqlite.core.DB.throwex(DB.java:859)
at org.sqlite.core.DB.executeBatch(DB.java:760)
at org.sqlite.core.CorePreparedStatement.executeBatch(CorePreparedStatement.java:77)
at Database.loadPersonData(Database.java:30)
at MainApp.main(MainApp.java:16)
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (Connection is closed)
at org.sqlite.core.DB.newSQLException(DB.java:890)
at org.sqlite.core.CoreStatement.internalClose(CoreStatement.java:109)
at org.sqlite.jdbc3.JDBC3Statement.close(JDBC3Statement.java:35)
at Database.loadPersonData(Database.java:44)
at MainApp.main(MainApp.java:16)