jeudi 29 octobre 2015

Eclipse SQLite database locked on Windows. Will not unlock

I have the strangest problem. I simply cannot get my database to unlock. Even after restarting my machine completely the Database will not unlock.

server.DatabaseException: SQL Error while creating new user DAO
at server.DAO.Users.createUser(Users.java:48)
at shared.model.ModelIndexerData.doUsers(ModelIndexerData.java:26)
at shared.model.ModelIndexerData.readInData(ModelIndexerData.java:15)
at server.dataimport.DataImport.deserializeXML(DataImport.java:106)
at server.dataimport.DataImport.<init>(DataImport.java:35)
at server.dataimport.Main.main(Main.java:12)
Caused by: java.sql.SQLException: [SQLITE_BUSY]  
The database file is locked (database is locked)
at org.sqlite.DB.newSQLException(DB.java:383)
at org.sqlite.DB.newSQLException(DB.java:387)
at org.sqlite.DB.execute(DB.java:339)
at org.sqlite.PrepStmt.execute(PrepStmt.java:65)
at server.DAO.Users.createUser(Users.java:45)

I have searched around and never seen anyone having the error where a database remains locked even after a system is restarted. I was trying to insert 1 user into a completely blank table.

I think the cause of the lock was closing out of my debugger in Eclipse before it went through the closing of the statement but I'm not certain.

Relevant code is:

public void createUser(String username, String password, String firstname, String lastname, String email) throws DatabaseException
{
    PreparedStatement pstmt = null;
    Connection conn = db.getConnection();
    try {
        pstmt = conn.prepareStatement("INSERT INTO USERS (USERNAME,PASSWORD,FIRSTNAME,LASTNAME,EMAIL) VALUES (?,?,?,?,?)");
        pstmt.setString(1, username);
        pstmt.setString(2, password);
        pstmt.setString(3, firstname);
        pstmt.setString(4, lastname);
        pstmt.setString(5, email);
        if (!pstmt.execute())
            throw new DatabaseException("Failed to execute prepared statement createUser UsersDAO");
    } catch (SQLException e) {
        throw new DatabaseException("SQL Error while creating new user DAO", e);
    } finally {
        Database.safeClose(pstmt);
    }

}

Aucun commentaire:

Enregistrer un commentaire