Created
August 24, 2020 18:02
-
-
Save marcelo-ochoa/c74907bb838e60196fdd06b9e4ab6cc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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