Source:
private int executeStatement(boolean silent, String user, String pw, String sql, String... args) { Connection connection = null; Statement statement = null; try { String replacedSql = sql; if (wizardModel.databaseConnection.contains("mysql")) { Class.forName("com.mysql.cj.jdbc.Driver").newInstance(); } else if (wizardModel.databaseConnection.contains("postgres")) { Class.forName("org.postgresql.Driver").newInstance(); replacedSql = replacedSql.replaceAll("`", "\""); } else { replacedSql = replacedSql.replaceAll("`", "\""); } String tempDatabaseConnection; if (sql.contains("create database")) { tempDatabaseConnection = wizardModel.databaseConnection.replace("@DBNAME@", ""); } else { tempDatabaseConnection = wizardModel.databaseConnection.replace("@DBNAME@", wizardModel.databaseName); } connection = DriverManager.getConnection(tempDatabaseConnection, user, pw); for (String arg : args) { arg = arg.replace(";", "&#094"); replacedSql = replacedSql.replaceFirst("\\?", arg); } statement = connection.createStatement(); return statement.executeUpdate(replacedSql); } catch (SQLException sqlex) { if (!silent) { log.warn("error executing sql: " + sql, sqlex); errors.put("Error executing sql: " + sql + " - " + sqlex.getMessage(), null); } } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) { log.error("Error generated", e); } finally { try { if (statement != null) { statement.close(); } } catch (SQLException e) { log.warn("Error while closing statement"); } try { if (connection != null) { connection.close(); } } catch (Exception e) { log.warn("Error while closing connection", e); } } return -1; }

Target:
private int executeStatement(boolean silent, String user, String pw, String sql, String... args) { Connection connection = null; Statement statement = null; try { String replacedSql = sql; if (isCurrentDatabase(DATABASE_MYSQL)) { Class.forName("com.mysql.cj.jdbc.Driver").newInstance(); } else if (isCurrentDatabase(DATABASE_POSTGRESQL)) { Class.forName("org.postgresql.Driver").newInstance(); replacedSql = replacedSql.replaceAll("`", "\""); } else { replacedSql = replacedSql.replaceAll("`", "\""); } String tempDatabaseConnection; if (sql.contains("create database")) { tempDatabaseConnection = wizardModel.databaseConnection.replace("@DBNAME@", ""); } else { tempDatabaseConnection = wizardModel.databaseConnection.replace("@DBNAME@", wizardModel.databaseName); } connection = DriverManager.getConnection(tempDatabaseConnection, user, pw); for (String arg : args) { arg = arg.replace(";", "&#094"); replacedSql = replacedSql.replaceFirst("\\?", arg); } statement = connection.createStatement(); return statement.executeUpdate(replacedSql); } catch (SQLException sqlex) { if (!silent) { log.warn("error executing sql: " + sql, sqlex); errors.put("Error executing sql: " + sql + " - " + sqlex.getMessage(), null); } } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) { log.error("Error generated", e); } finally { try { if (statement != null) { statement.close(); } } catch (SQLException e) { log.warn("Error while closing statement"); } try { if (connection != null) { connection.close(); } } catch (Exception e) { log.warn("Error while closing connection", e); } } return -1; }