Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for SQL queries accumulation in multiple requests on same testcase #210

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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