Skip to content

Commit 512523b

Browse files
committed
fix for SQL queries accumulation in multiple requests on same testcase
1 parent 6cad4da commit 512523b

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/main/java/org/owasp/benchmark/helpers/DatabaseHelper.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.owasp.esapi.ESAPI;
3434

3535
public class DatabaseHelper {
36-
private static Statement stmt;
3736
private static Connection conn;
3837
public static org.springframework.jdbc.core.JdbcTemplate JDBCtemplate;
3938
public static org.owasp.benchmark.helpers.HibernateUtil hibernateUtil =
@@ -120,13 +119,11 @@ public static java.sql.Statement getSqlStatement() {
120119
if (conn == null) {
121120
getSqlConnection();
122121
}
123-
124-
if (stmt == null) {
125-
try {
126-
stmt = conn.createStatement();
127-
} catch (SQLException e) {
128-
System.out.println("Problem with database init.");
129-
}
122+
Statement stmt = null;
123+
try {
124+
stmt = conn.createStatement();
125+
} catch (SQLException e) {
126+
System.out.println("Problem with database init.");
130127
}
131128

132129
return stmt;
@@ -172,9 +169,7 @@ public static java.sql.Connection getSqlConnection() {
172169
}
173170

174171
public static void executeSQLCommand(String sql) throws Exception {
175-
if (stmt == null) {
176-
getSqlStatement();
177-
}
172+
Statement stmt = getSqlStatement();
178173
stmt.executeUpdate(sql);
179174
}
180175

0 commit comments

Comments
 (0)