In a first method, I create the database, if not exists :
Class.forName("org.sqlite.JDBC");
Connection connection = null;
connection = DriverManager.getConnection("jdbc:sqlite:" + Gdx.files.internal("mjvsworld.db"));
Statement statement = connection.createStatement();
statement.executeUpdate("CREATE TABLE IF NOT EXISTS GLOBAL(ID INTEGER PRIMARY KEY" +
" AUTOINCREMENT, NAME TEXT, MAXPUNTUATION INTEGER)");
if (statement != null) statement.close();
if (connection != null) connection.close();
In a second method, in other way (I do the same, changin' the update query), I try to read if some row in table was inserted, of If table was created now, insert it :
statement.executeUpdate("INSERT OR REPLACE INTO GLOBAL (ID, NAME, MAXPUNTUATION) VALUES "
+"(1, 'Elvis', "+maxpoints+")");
In another call, after in the project, I try to update only one row (ID=1), and **in this one, gives me error **:
statement.executeUpdate("UPDATE GLOBAL set MAXPUNTUATION = "+puntos+" AND NAME = '"+name+"' where ID=1;");
ยด
**ERROR CODE : **
java.sql.SQLException: database is locked
at org.sqlite.NativeDB.throwex(NativeDB.java:210)
at org.sqlite.NativeDB._exec(Native Method)
at org.sqlite.Stmt.executeUpdate(Stmt.java:152)
at pack.util.DbConnection.actualizarMaxPuntuacion(DbConnection.java:94)
at pack.maingame.Platform.finalizarJuego(Platform.java:1060)
at pack.maingame.Platform.configurarDeteccionesJugador1(Platform.java:686)
at pack.maingame.Platform.render(Platform.java:443)
at pack.visual.GameScreen.render(GameScreen.java:51)
at com.badlogic.gdx.Game.render(Game.java:46)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:208)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:115)
DbConnection.java:94 `equals to last executeUpdate I post.`
I need help with this. Thanks. (I don't use commit, I tried to use it and gives me error too)