use of com.mysql.cj.Query in project aws-mysql-jdbc by awslabs.
the class ConnectionRegressionTest method testBug97714.
/**
* Test fix for Bug#97714 (30570249), Contribution: Expose elapsed time for query interceptor to avoid hacky thread local implementations.
*
* @throws Exception
*/
@Test
public void testBug97714() throws Exception {
assumeFalse(isServerRunningOnWindows(), "SLEEP() is not precise enough on Windows.");
boolean useSPS = false;
do {
final String testCase = String.format("Case: [useServerPrepStmts: %s]", useSPS ? "Y" : "N");
Properties props = new Properties();
props.setProperty(PropertyKey.sslMode.getKeyName(), SslMode.DISABLED.name());
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), Boolean.toString(useSPS));
Connection testConn = getConnectionWithProps(props);
// Statement
Statement testStmt = testConn.createStatement();
assertEquals(StatementImpl.class, testStmt.getClass(), testCase);
this.rs = testStmt.executeQuery("SELECT SLEEP(0.25)");
assertTrue(((Query) testStmt).getExecuteTime() >= 250, testCase);
// PreparedStatement
PreparedStatement testPstmt = testConn.prepareStatement("SELECT SLEEP(0.25)");
assertEquals(useSPS ? ServerPreparedStatement.class : ClientPreparedStatement.class, testPstmt.getClass(), testCase);
this.rs = testPstmt.executeQuery();
assertTrue(((Query) testPstmt).getExecuteTime() >= 250, testCase);
testConn.close();
} while (useSPS = !useSPS);
}
use of com.mysql.cj.Query in project JavaSegundasQuintas by ecteruel.
the class ConnectionRegressionTest method testBug97714.
/**
* Test fix for Bug#97714 (30570249), Contribution: Expose elapsed time for query interceptor to avoid hacky thread local implementations.
*
* @throws Exception
*/
@Test
public void testBug97714() throws Exception {
assumeFalse(isServerRunningOnWindows(), "SLEEP() is not precise enough on Windows.");
boolean useSPS = false;
do {
final String testCase = String.format("Case: [useServerPrepStmts: %s]", useSPS ? "Y" : "N");
Properties props = new Properties();
props.setProperty(PropertyKey.sslMode.getKeyName(), "DISABLED");
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), Boolean.toString(useSPS));
Connection testConn = getConnectionWithProps(props);
// Statement
Statement testStmt = testConn.createStatement();
assertEquals(StatementImpl.class, testStmt.getClass(), testCase);
this.rs = testStmt.executeQuery("SELECT SLEEP(0.25)");
assertTrue(((Query) testStmt).getExecuteTime() >= 250, testCase);
// PreparedStatement
PreparedStatement testPstmt = testConn.prepareStatement("SELECT SLEEP(0.25)");
assertEquals(useSPS ? ServerPreparedStatement.class : ClientPreparedStatement.class, testPstmt.getClass(), testCase);
this.rs = testPstmt.executeQuery();
assertTrue(((Query) testPstmt).getExecuteTime() >= 250, testCase);
testConn.close();
} while (useSPS = !useSPS);
}
use of com.mysql.cj.Query in project ABC by RuiPinto96274.
the class ConnectionRegressionTest method testBug97714.
/**
* Test fix for Bug#97714 (30570249), Contribution: Expose elapsed time for query interceptor to avoid hacky thread local implementations.
*
* @throws Exception
*/
@Test
public void testBug97714() throws Exception {
assumeFalse(isServerRunningOnWindows(), "SLEEP() is not precise enough on Windows.");
boolean useSPS = false;
do {
final String testCase = String.format("Case: [useServerPrepStmts: %s]", useSPS ? "Y" : "N");
Properties props = new Properties();
props.setProperty(PropertyKey.sslMode.getKeyName(), "DISABLED");
props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), Boolean.toString(useSPS));
Connection testConn = getConnectionWithProps(props);
// Statement
Statement testStmt = testConn.createStatement();
assertEquals(StatementImpl.class, testStmt.getClass(), testCase);
this.rs = testStmt.executeQuery("SELECT SLEEP(0.25)");
assertTrue(((Query) testStmt).getExecuteTime() >= 250, testCase);
// PreparedStatement
PreparedStatement testPstmt = testConn.prepareStatement("SELECT SLEEP(0.25)");
assertEquals(useSPS ? ServerPreparedStatement.class : ClientPreparedStatement.class, testPstmt.getClass(), testCase);
this.rs = testPstmt.executeQuery();
assertTrue(((Query) testPstmt).getExecuteTime() >= 250, testCase);
testConn.close();
} while (useSPS = !useSPS);
}
Aggregations