@Override public int getQueryTimeout() throws SQLException { return rawStatement.getQueryTimeout(); }
@Override public int getQueryTimeout() throws SQLException { return rawStatement.getQueryTimeout(); }
/** {@inheritDoc} */ @Override public int getQueryTimeout() throws SQLException { return delegate.getQueryTimeout(); }
/** * Test for reading of default query timeout */ @Test public void testDefaultGetQueryTimeout() throws SQLException { try (PreparedStatement stmt = connection.prepareStatement(SYS_VERSION_SQL)) { int timeoutValue = stmt.getQueryTimeout(); assertEquals(0L, timeoutValue); } }
/** * Test setting a valid timeout */ @Test public void testValidSetQueryTimeout() throws SQLException { try (PreparedStatement stmt = connection.prepareStatement(SYS_VERSION_SQL)) { //Setting positive value int valueToSet = new Random(20150304).nextInt(59)+1; logger.info("Setting timeout as {} seconds", valueToSet); stmt.setQueryTimeout(valueToSet); assertEquals(valueToSet, stmt.getQueryTimeout()); } }
try (PreparedStatement stmt = connection.prepareStatement(SYS_RANDOM_SQL)) { stmt.setQueryTimeout(timeoutDuration); logger.info("Set a timeout of {} seconds", stmt.getQueryTimeout()); ResultSet rs = stmt.executeQuery();
logger.info("Set a timeout of {} seconds", pStmt.getQueryTimeout());
@Override public int getQueryTimeout() throws SQLException { return ps.getQueryTimeout(); }
@Override public int getQueryTimeout() throws SQLException { return ps.getQueryTimeout(); }
defaultQueryTimeout = stmt.getQueryTimeout(); } catch (SQLException e) { LOG.error("getMaxRows error", e);
@Test public void testZeroCustomQueryTimeout() throws Exception { // Arrange Properties connectionProperties = new Properties(); connectionProperties.setProperty("phoenix.query.timeoutMs", "0"); Connection connection = DriverManager.getConnection(getUrl(), connectionProperties); PreparedStatement stmt = connection.prepareStatement("SELECT * FROM " + ATABLE); PhoenixStatement phoenixStmt = stmt.unwrap(PhoenixStatement.class); // Assert assertEquals(0, stmt.getQueryTimeout()); assertEquals(0, phoenixStmt.getQueryTimeoutInMillis()); }
@Test /** * Validates that setting custom phoenix query timeout using * the phoenix.query.timeoutMs config property is honored. */ public void testCustomQueryTimeout() throws Exception { // Arrange Properties connectionProperties = new Properties(); connectionProperties.setProperty("phoenix.query.timeoutMs", "2350"); Connection connection = DriverManager.getConnection(getUrl(), connectionProperties); PreparedStatement stmt = connection.prepareStatement("SELECT * FROM " + ATABLE); PhoenixStatement phoenixStmt = stmt.unwrap(PhoenixStatement.class); // Assert assertEquals(3, stmt.getQueryTimeout()); assertEquals(2350, phoenixStmt.getQueryTimeoutInMillis()); }
@Test public void testCallingSetMethodsOnStatementInterface() throws SQLException { String sql = "select * from prepstmt_test where col1 = ?"; PreparedStatement prep = getPreparedStatement(sql); prep.setMaxRows(1); assertEquals(1, prep.getMaxRows()); prep.setQueryTimeout(12); // The SQLLite driver returns the value in ms assertEquals(("SQLite".equals(db) ? 3000 : 12), prep.getQueryTimeout()); prep.close(); }
@Test /** * Validates if a user sets the timeout to zero that we store the timeout * in millis as the Integer.MAX_VALUE. */ public void testSettingZeroQueryTimeoutViaJdbc() throws Exception { // Arrange Connection connection = DriverManager.getConnection(getUrl()); PreparedStatement stmt = connection.prepareStatement("SELECT * FROM " + ATABLE); PhoenixStatement phoenixStmt = stmt.unwrap(PhoenixStatement.class); // Act stmt.setQueryTimeout(0); // Assert assertEquals(Integer.MAX_VALUE / 1000, stmt.getQueryTimeout()); assertEquals(Integer.MAX_VALUE, phoenixStmt.getQueryTimeoutInMillis()); }
@Test /** * Validates that if a user sets the query timeout via the * stmt.setQueryTimeout() JDBC method, we correctly store the timeout * in both milliseconds and seconds. */ public void testSettingQueryTimeoutViaJdbc() throws Exception { // Arrange Connection connection = DriverManager.getConnection(getUrl()); PreparedStatement stmt = connection.prepareStatement("SELECT * FROM " + ATABLE); PhoenixStatement phoenixStmt = stmt.unwrap(PhoenixStatement.class); // Act stmt.setQueryTimeout(3); // Assert assertEquals(3, stmt.getQueryTimeout()); assertEquals(3000, phoenixStmt.getQueryTimeoutInMillis()); }
@Test /** * Validates that is negative value is supplied we set the timeout to the default. */ public void testSettingNegativeQueryTimeoutViaJdbc() throws Exception { // Arrange Connection connection = DriverManager.getConnection(getUrl()); PreparedStatement stmt = connection.prepareStatement("SELECT * FROM " + ATABLE); PhoenixStatement phoenixStmt = stmt.unwrap(PhoenixStatement.class); PhoenixConnection phoenixConnection = connection.unwrap(PhoenixConnection.class); int defaultQueryTimeout = phoenixConnection.getQueryServices().getProps().getInt(QueryServices.THREAD_TIMEOUT_MS_ATTRIB, QueryServicesOptions.DEFAULT_THREAD_TIMEOUT_MS); // Act stmt.setQueryTimeout(-1); // Assert assertEquals(defaultQueryTimeout / 1000, stmt.getQueryTimeout()); assertEquals(defaultQueryTimeout, phoenixStmt.getQueryTimeoutInMillis()); }
defaultQueryTimeout = stmt.getQueryTimeout(); } catch (SQLException e) { LOG.error("getMaxRows error", e);
@Override public int getQueryTimeout() throws SQLException { checkState(); return realPreparedStatement.getQueryTimeout(); }
public int getQueryTimeout() throws SQLException { Profiler profiler = _profilerPoint.start(); try { return _preparedStatement.getQueryTimeout(); } finally { profiler.finish(); } }
/** Tests that getQueryTimeout() indicates no timeout set. */ @Test public void testGetQueryTimeoutSaysNoTimeout() throws SQLException { try(PreparedStatement statement = getConnection().prepareStatement(SYS_VERSION_SQL)) { assertThat( statement.getQueryTimeout(), equalTo( 0 ) ); } }