Created
August 24, 2020 18:01
-
-
Save marcelo-ochoa/75bef974d38f2086eb40e59c3b7a0454 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 StressTestUpdate extends StressTest { | |
public StressTestUpdate() { | |
} | |
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("update TESTCOLLECTION set LAST_MODIFIED = systimestamp where id = ?"); | |
insPs.setString(1, selectId); | |
insPs.execute(); | |
connection.commit(); | |
addUpdateStatements(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