Persistence Exception: Database locked

Discussion in 'Plugin Development' started by TheA13X, Apr 18, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    TheA13X

    My Experience shows me, that there aren't many people in here, knowing about Bukkits local database (the Ebean ORM), but as the actual problem seems to be a SQLProblem, maybe someone knows the answer
    Hello colleagues and professors,
    My problem is that sometimes the following Exception appears when the plugin saves a "row":
    Code:
    Java.lang.PersistenceException: Java.sqlite.SQLException: Database Locked

    As I'm using a SQLite Database, I think that means, that there's another open connection.
    the code:
    Code:java
    1. Alectivation work=bean.find(Alectivation.class).where().ieq("UniqueId",p.getUniqueId().toString()).findUnique(); //Ebean Connection
    2. PreparedStatement sql=Activator.getC().prepareStatement("SELECT * FROM `ActivationData` WHERE Name = ?",
    3. ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    4. sql.setString(1, p.getName());
    5. ResultSet rs=sql.executeQuery();//MySQL Connection
    6. rs.next();
    7. ...
    8. work.setReady(true);
    9. bean.update(work);
    10. rs.updateBoolean("ready", true);
    11. rs.updateRow();

    I have a second open connection in this class, but this one is connecting to an other (MySQL) database.
    In fact I opened an connection through Ebean before in the main class, but as I used the save-method
    it should been closed. And if not, how can I close connection on Ebean?

    So how can I fix it?
     
  2. Offline

    TheA13X

    Sorry. Wrong Exception.
    It's the
    Code:
    javax.Persistance.RollbackException: java.sql.SQLException: database is locked
    This Exception is thrown when one Transaction tries to write/read data, which are read/written by another Transaction.
    This spawn another question: How to find out, if a transaction is completed, so I can do an other query?
     
Thread Status:
Not open for further replies.

Share This Page