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{
try (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());
}
try (PreparedStatement updateStatement = connection.prepareStatement(sql)) {
updateStatement.executeUpdate();