preprepare statement now specifies ResultSet type

This commit is contained in:
quentin 2022-04-18 16:12:15 -05:00
parent d3aea69b9c
commit bd41943c1b
3 changed files with 21 additions and 13 deletions

1
.idea/dataSources.xml generated
View File

@ -9,6 +9,7 @@
<working-dir>$ProjectFileDir$</working-dir>
<driver-properties>
<property name="allowPublicKeyRetrieval" value="TRUE" />
<property name="serverTimezone" value="UTC" />
</driver-properties>
</data-source>
</component>

View File

@ -33,3 +33,10 @@ commands:
description: Returns the total heat of a player
permission: adminutils.warnings.getHeat
getBanTime:
usage: /<command> player
description: Returns when a players ban would be over
permission: adminutils.warnings.getBanTime

View File

@ -15,7 +15,7 @@ public class Database {
String query = "DELETE FROM minecraft.warnings w WHERE w.warnId = ?;";
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setInt(1, id);
preparedStatement.executeUpdate();
con.close();
@ -38,7 +38,7 @@ public class Database {
}
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setObject(1, newValue);
preparedStatement.setInt(2, id);
preparedStatement.executeUpdate();
@ -51,7 +51,7 @@ public class Database {
String query = "SELECT * FROM minecraft.warnings w WHERE player=?;";
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setString(1, UUID);
return new ResultSetConnectionWrapper(preparedStatement.executeQuery(), con);
}
@ -61,7 +61,7 @@ public class Database {
String query = "SELECT * FROM minecraft.warnings w WHERE player=? LIMIT ?;";
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setString(1, UUID);
preparedStatement.setInt(2, limit);
return new ResultSetConnectionWrapper(preparedStatement.executeQuery(), con);
@ -78,7 +78,7 @@ public class Database {
return null;
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setString(1, UUID);
preparedStatement.setInt(2, limit);
return new ResultSetConnectionWrapper(preparedStatement.executeQuery(), con);
@ -95,7 +95,7 @@ public class Database {
return null;
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setString(1, UUID);
return new ResultSetConnectionWrapper(preparedStatement.executeQuery(), con);
}
@ -105,7 +105,7 @@ public class Database {
String query = "SELECT * FROM minecraft.warning_types";
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
return new ResultSetConnectionWrapper(preparedStatement.executeQuery(), con);
}
@ -114,7 +114,7 @@ public class Database {
String query = "SELECT * FROM minecraft.warning_types w where w.warnId=?";
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setInt(1, id);
return new ResultSetConnectionWrapper(preparedStatement.executeQuery(), con);
}
@ -124,7 +124,7 @@ public class Database {
String query = "SELECT * FROM minecraft.warning_types w where w.name=?";
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setString(1, type.toUpperCase(Locale.ROOT));
return new ResultSetConnectionWrapper(preparedStatement.executeQuery(), con);
}
@ -135,7 +135,7 @@ public class Database {
for (int i = 0; i < offences; i++) {
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setInt(1, typeId);
preparedStatement.setDate(2, today);
preparedStatement.setString(3, UUID);
@ -151,7 +151,7 @@ public class Database {
String query = "INSERT INTO minecraft.warnings (warnType, date, player, description) VALUES (?, ?, ?, ?);";
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setInt(1, typeId);
preparedStatement.setDate(2, today);
preparedStatement.setString(3, UUID);
@ -167,7 +167,7 @@ public class Database {
for (int i = 0; i < offences; i++) {
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setInt(1, typeId);
preparedStatement.setDate(2, today);
preparedStatement.setString(3, UUID);
@ -182,7 +182,7 @@ public class Database {
String query = "INSERT INTO minecraft.warnings (warnType, date, player, description) VALUES (?, ?, ?, null);";
Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement preparedStatement = con.prepareStatement(query);
PreparedStatement preparedStatement = con.prepareStatement(query, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
preparedStatement.setInt(1, typeId);
preparedStatement.setDate(2, today);
preparedStatement.setString(3, UUID);