mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-02-16 02:21:06 +00:00
Sql return generated keys fix
This commit is contained in:
@@ -7,10 +7,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.*;
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -127,7 +124,7 @@ public class DatabaseQueue extends SQLite {
|
|||||||
int id = -1;
|
int id = -1;
|
||||||
try {
|
try {
|
||||||
conn = getSQLConnection();
|
conn = getSQLConnection();
|
||||||
ps = conn.prepareStatement(statement);
|
ps = conn.prepareStatement(statement, Statement.RETURN_GENERATED_KEYS);
|
||||||
Iterator<Object> it = params.iterator();
|
Iterator<Object> it = params.iterator();
|
||||||
int paramIndex = 1;
|
int paramIndex = 1;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@@ -137,7 +134,7 @@ public class DatabaseQueue extends SQLite {
|
|||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
ResultSet rs = ps.getGeneratedKeys();
|
ResultSet rs = ps.getGeneratedKeys();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
id = rs.getInt(COLUMNS.ID.name);
|
id = rs.getInt(1);
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
BetterRTP.getInstance().getLogger().log(Level.SEVERE, Errors.sqlConnectionExecute(), ex);
|
||||||
|
|||||||
Reference in New Issue
Block a user