Skip to content

Instantly share code, notes, and snippets.

@marcelo-ochoa
Created August 24, 2020 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelo-ochoa/c74907bb838e60196fdd06b9e4ab6cc7 to your computer and use it in GitHub Desktop.
Save marcelo-ochoa/c74907bb838e60196fdd06b9e4ab6cc7 to your computer and use it in GitHub Desktop.
package com.dom.benchmarking.swingbench.testcollection;
import com.dom.benchmarking.swingbench.event.JdbcTaskEvent;
import com.dom.benchmarking.swingbench.kernel.SwingBenchException;
import com.dom.benchmarking.swingbench.kernel.SwingBenchTask;
import com.dom.util.RandomUtilities;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Map;
public final class StressTestDelete extends StressTest {
public StressTestDelete() {
}
public void execute(Map parameters) throws SwingBenchException {
Connection connection = (Connection) parameters.get(SwingBenchTask.JDBC_CONNECTION);
PreparedStatement insPs = null;
boolean success = true;
initJdbcTask();
long executeStart = System.nanoTime();
try {
String selectId = RandomUtilities.randomAlpha(32, 32);
insPs = connection.prepareStatement("delete from TESTCOLLECTION where id = ?");
insPs.setString(1, selectId);
insPs.execute();
connection.commit();
addDeleteStatements(1);
addCommitStatements(1);
} catch (SQLException ex) {
success = false;
System.out.println(ex);
} finally {
try {
insPs.close();
} catch (SQLException e) {
}
processTransactionEvent(new JdbcTaskEvent(this, getId(), (System.nanoTime() -
executeStart), success, getSelectStatements(), getInsertStatements(), getUpdateStatements(), getDeleteStatements(), getCommitStatements(), getRollbackStatements()));
}
}
public void close() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment