DataBase Fixed

This commit is contained in:
mlus 2024-08-04 17:46:38 +08:00
parent 14686a930f
commit bd4694e44b

View File

@ -26,9 +26,9 @@ public class JDBCsetUp {
public static void executeUpdate(String sql) throws SQLException{ public static void executeUpdate(String sql) throws SQLException{
try (Connection connection = getConnection()) { try (Connection connection = getConnection()) {
PreparedStatement useStatement = connection.prepareStatement("USE ?"); try (Statement useStatement = connection.createStatement()) {
useStatement.setString(1, JdbcConfig.DATABASE_NAME.get()); useStatement.execute("USE " + JdbcConfig.DATABASE_NAME.get());
useStatement.executeUpdate(); }
try (PreparedStatement updateStatement = connection.prepareStatement(sql)) { try (PreparedStatement updateStatement = connection.prepareStatement(sql)) {
updateStatement.executeUpdate(); updateStatement.executeUpdate();