Created
August 24, 2020 18:00
-
-
Save marcelo-ochoa/197ca03238072ca45ea1db46873ee801 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.ResultSet; | |
import java.sql.SQLException; | |
import java.util.Map; | |
public final class StressTestSelect extends StressTest { | |
public StressTestSelect() { | |
} | |
public void execute(Map parameters) throws SwingBenchException { | |
Connection connection = (Connection) parameters.get(SwingBenchTask.JDBC_CONNECTION); | |
PreparedStatement selPs = null; | |
ResultSet rs = null; | |
boolean success = true; | |
initJdbcTask(); | |
long executeStart = System.nanoTime(); | |
try { | |
String selectId = RandomUtilities.randomAlpha(32, 32); | |
selPs = connection.prepareStatement("select * from TESTCOLLECTION where id = ?"); | |
selPs.setString(1, selectId); | |
rs = selPs.executeQuery(); | |
addSelectStatements(1); | |
} catch (SQLException ex) { | |
success = false; | |
System.out.println(ex); | |
} finally { | |
try { | |
rs.close(); | |
selPs.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