Skip to content

Commit

Permalink
fix for SQL queries accumulation in multiple requests on same testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
kishan-k2io committed Sep 8, 2023
1 parent 6cad4da commit 512523b
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 512523b

Please sign in to comment.