Hello everyone on StackOverflow! I am trying to update a specific row in an SQLite DB, but it doesn't seem to work. This is what the database looks like.
-----------------------
_id | user | coins
-----------------------
1 | me | 20
-----------------------
And this is what my code looks like:
public static void updateUserWallet() throws SQLException {
try {
int coins;
Class.forName("org.sqlite.JDBC");
Connection connection = DriverManager.getConnection("jdbc:sqlite:Database.db");
String query = "Select * from userSettings WHERE user = " + "'" + lastUser + "'";
Statement statement = connection.createStatement();
ResultSet result = statement.executeQuery(query);
while (result.next()) {
coins = result.getInt("coins");
result.updateInt("coins", 10);
result.updateRow();
}
} catch (Exception e) {
e.printStackTrace();
}
}
Selecting the table and stuff works, but the second I execute this code, it crashes:
result.updateInt("coins", 10);
result.updateRow();
With this error:
java.sql.SQLException: not implemented by SQLite JDBC driver
at org.sqlite.jdbc4.JDBC4ResultSet.unused(JDBC4ResultSet.java:321)
at org.sqlite.jdbc4.JDBC4ResultSet.updateInt(JDBC4ResultSet.java:452)
at dysanix.advanced.kikbot.main.updateUserWallet(main.java:367)
at dysanix.advanced.kikbot.main$1.cmdGameRoll(main.java:266)
at dysanix.advanced.kikbot.main$1.run(main.java:142)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
-----------------------
_id | user | coins
-----------------------
1 | me | 20
-----------------------
All I want to do, is update the "20" to "10" (or another number). How would I go around doing this properly? Thanks!
Aucun commentaire:
Enregistrer un commentaire