Skip to content

Commit

Permalink
And for update
Browse files Browse the repository at this point in the history
  • Loading branch information
mlus-asuka committed Aug 4, 2024
1 parent bd4694e commit 053758e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/vip/fubuki/playersync/util/JDBCsetUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public static Connection getConnection() throws SQLException {

public static QueryResult executeQuery(String sql) throws SQLException{
Connection connection = getConnection();
PreparedStatement useStatement = connection.prepareStatement("USE ?");
useStatement.setString(1, JdbcConfig.DATABASE_NAME.get());
useStatement.executeUpdate();

try (Statement useStatement = connection.createStatement()) {
useStatement.execute("USE " + JdbcConfig.DATABASE_NAME.get());
}
PreparedStatement queryStatement = connection.prepareStatement(sql);
ResultSet resultSet = queryStatement.executeQuery();
return new QueryResult(connection,resultSet);
Expand All @@ -39,9 +39,9 @@ public static void executeUpdate(String sql) throws SQLException{
public static void Update(String sql, String... argument) throws SQLException{
Connection connection = getConnection();

PreparedStatement useStatement = connection.prepareStatement("USE ?");
useStatement.setString(1, JdbcConfig.DATABASE_NAME.get());
useStatement.executeUpdate();
try (Statement useStatement = connection.createStatement()) {
useStatement.execute("USE " + JdbcConfig.DATABASE_NAME.get());
}

PreparedStatement updateStatement = connection.prepareStatement(sql);
for (int i = 1; i <= argument.length; i++) {
Expand Down

0 comments on commit 053758e

Please sign in to comment.