Skip to content

Commit

Permalink
Merge pull request #210 from kishan-k2io/master
Browse files Browse the repository at this point in the history
fix for SQL queries accumulation in multiple requests on same testcase
  • Loading branch information
davewichers authored Sep 13, 2023
2 parents 6cad4da + 512523b commit ab3bd34
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/main/java/org/owasp/benchmark/helpers/DatabaseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.owasp.esapi.ESAPI;

public class DatabaseHelper {
private static Statement stmt;
private static Connection conn;
public static org.springframework.jdbc.core.JdbcTemplate JDBCtemplate;
public static org.owasp.benchmark.helpers.HibernateUtil hibernateUtil =
Expand Down Expand Up @@ -120,13 +119,11 @@ public static java.sql.Statement getSqlStatement() {
if (conn == null) {
getSqlConnection();
}

if (stmt == null) {
try {
stmt = conn.createStatement();
} catch (SQLException e) {
System.out.println("Problem with database init.");
}
Statement stmt = null;
try {
stmt = conn.createStatement();
} catch (SQLException e) {
System.out.println("Problem with database init.");
}

return stmt;
Expand Down Expand Up @@ -172,9 +169,7 @@ public static java.sql.Connection getSqlConnection() {
}

public static void executeSQLCommand(String sql) throws Exception {
if (stmt == null) {
getSqlStatement();
}
Statement stmt = getSqlStatement();
stmt.executeUpdate(sql);
}

Expand Down

0 comments on commit ab3bd34

Please sign in to comment.