org.apache.calcite.avatica.Meta.StatementHandle Java Examples
The following examples show how to use
org.apache.calcite.avatica.Meta.StatementHandle.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DremioJdbc41Factory.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public DremioJdbc41PreparedStatement newPreparedStatement(AvaticaConnection connection, StatementHandle h, Meta.Signature signature, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { DremioConnectionImpl dremioConnection = (DremioConnectionImpl) connection; DremioClient client = dremioConnection.getClient(); if (dremioConnection.getConfig().isServerPreparedStatementDisabled() || !client.getSupportedMethods().contains(ServerMethod.PREPARED_STATEMENT)) { // fallback to client side prepared statement return new DremioJdbc41PreparedStatement(dremioConnection, h, signature, null, resultSetType, resultSetConcurrency, resultSetHoldability); } return newServerPreparedStatement(dremioConnection, h, signature, resultSetType, resultSetConcurrency, resultSetHoldability); }
Example #2
Source File: AvaticaClosedPreparedStatementTest.java From calcite-avatica with Apache License 2.0 | 6 votes |
@Override protected PreparedStatement newInstance() throws Exception { UnregisteredDriver driver = new TestDriver(); AvaticaConnection connection = new AvaticaConnection(driver, driver.createFactory(), "jdbc:avatica", new Properties()) { }; StatementHandle handle = mock(StatementHandle.class); Signature signature = new Signature(Collections.emptyList(), "", Collections.emptyList(), Collections.emptyMap(), null, Meta.StatementType.SELECT); AvaticaPreparedStatement preparedStatement = new AvaticaPreparedStatement(connection, handle, signature, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT) { }; preparedStatement.close(); assertTrue("Prepared statement is not closed", preparedStatement.isClosed()); return preparedStatement; }
Example #3
Source File: AvaticaClosedResultSetTest.java From calcite-avatica with Apache License 2.0 | 6 votes |
@Override protected ResultSet newInstance() throws Exception { UnregisteredDriver driver = new TestDriver(); AvaticaConnection connection = new AvaticaConnection(driver, driver.createFactory(), "jdbc:avatica", new Properties()) { }; StatementHandle handle = mock(StatementHandle.class); AvaticaStatement statement = new AvaticaStatement(connection, handle, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT) { }; Signature signature = new Signature(Collections.emptyList(), "", Collections.emptyList(), Collections.emptyMap(), null, Meta.StatementType.SELECT); AvaticaResultSet resultSet = new AvaticaResultSet(statement, new QueryState(""), signature, null, DateTimeUtils.UTC_ZONE, null); resultSet.close(); assertTrue("Resultset is not closed", resultSet.isClosed()); return resultSet; }
Example #4
Source File: ProtobufSerializationTest.java From calcite-avatica with Apache License 2.0 | 6 votes |
@Test public void testExecuteSerialization() throws Exception { Service.ExecuteRequest executeRequest = new Service.ExecuteRequest( new StatementHandle("connection", 12345, getSignature()), getTypedValues(), 0); Requests.ExecuteRequest pbExecuteRequest = executeRequest.serialize(); ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); pbExecuteRequest.writeTo(baos); byte[] serialized = baos.toByteArray(); baos.reset(); WireMessage wireMsg = WireMessage.newBuilder().setName(Requests.ExecuteRequest.class.getName()) .setWrappedMessage(UnsafeByteOperations.unsafeWrap(serialized)).build(); wireMsg.writeTo(baos); serialized = baos.toByteArray(); ProtobufTranslation translator = new ProtobufTranslationImpl(); Request newRequest = translator.parseRequest(serialized); Assert.assertEquals(executeRequest, newRequest); }
Example #5
Source File: JdbcMetaTest.java From calcite-avatica with Apache License 2.0 | 5 votes |
@Test public void testPrepareAndExecuteSetsMaxRows() throws Exception { final String id = UUID.randomUUID().toString(); final int statementId = 12345; final String sql = "SELECT * FROM FOO"; final int maxRows = 500; JdbcMeta meta = Mockito.mock(JdbcMeta.class); PreparedStatement statement = Mockito.mock(PreparedStatement.class); @SuppressWarnings("unchecked") Cache<Integer, StatementInfo> statementCache = (Cache<Integer, StatementInfo>) Mockito.mock(Cache.class); Signature signature = Mockito.mock(Signature.class); final StatementInfo statementInfo = new StatementInfo(statement); final StatementHandle statementHandle = new StatementHandle(id, statementId, signature); Mockito.when(meta.getStatementCache()).thenReturn(statementCache); Mockito.when(statementCache.getIfPresent(statementId)).thenReturn(statementInfo); Mockito.when(statement.getResultSet()).thenReturn(null); // The real methods Mockito.when(meta.prepareAndExecute(statementHandle, sql, maxRows, 50, null)) .thenCallRealMethod(); Mockito.doCallRealMethod().when(meta).setMaxRows(statement, maxRows); // Call our method meta.prepareAndExecute(statementHandle, sql, maxRows, 50, null); // Verify we called setMaxRows with the right value Mockito.verify(statement).setMaxRows(maxRows); }
Example #6
Source File: DremioJdbc41Factory.java From dremio-oss with Apache License 2.0 | 5 votes |
DremioJdbc41PreparedStatement(DremioConnectionImpl connection, StatementHandle h, Meta.Signature signature, com.dremio.exec.proto.UserProtos.PreparedStatement pstmt, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { super(connection, h, signature, pstmt, resultSetType, resultSetConcurrency, resultSetHoldability); }
Example #7
Source File: DremioJdbc41Factory.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public DremioStatementImpl newStatement(AvaticaConnection connection, StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) { return new DremioStatementImpl((DremioConnectionImpl) connection, h, resultSetType, resultSetConcurrency, resultSetHoldability); }
Example #8
Source File: AvaticaClosedStatementTest.java From calcite-avatica with Apache License 2.0 | 5 votes |
@Override protected Statement newInstance() throws Exception { UnregisteredDriver driver = new TestDriver(); AvaticaConnection connection = new AvaticaConnection(driver, driver.createFactory(), "jdbc:avatica", new Properties()) { }; StatementHandle handle = mock(StatementHandle.class); AvaticaStatement statement = new AvaticaStatement(connection, handle, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT) { }; statement.close(); assertTrue("Statement is not closed", statement.isClosed()); return statement; }
Example #9
Source File: DremioPreparedStatementImpl.java From dremio-oss with Apache License 2.0 | 5 votes |
protected DremioPreparedStatementImpl(DremioConnectionImpl connection, StatementHandle h, Meta.Signature signature, PreparedStatement preparedStatementHandle, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { super(connection, h, signature, resultSetType, resultSetConcurrency, resultSetHoldability); connection.openStatementsRegistry.addStatement(this); this.preparedStatementHandle = preparedStatementHandle; if (preparedStatementHandle != null) { ((DremioColumnMetaDataList) signature.columns).updateColumnMetaData(preparedStatementHandle.getColumnsList()); } }
Example #10
Source File: KylinStatement.java From kylin with Apache License 2.0 | 4 votes |
protected KylinStatement(AvaticaConnection connection, StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) { super(connection, h, resultSetType, resultSetConcurrency, resultSetHoldability); }
Example #11
Source File: KylinPreparedStatement.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
protected KylinPreparedStatement(AvaticaConnection connection, StatementHandle h, Signature signature, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { super(connection, h, signature, resultSetType, resultSetConcurrency, resultSetHoldability); if (this.handle.signature == null) this.handle.signature = signature; }
Example #12
Source File: KylinJdbcFactory.java From kylin with Apache License 2.0 | 4 votes |
@Override public AvaticaPreparedStatement newPreparedStatement(AvaticaConnection connection, StatementHandle h, Signature signature, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return new KylinPreparedStatement((KylinConnection) connection, h, signature, resultSetType, resultSetConcurrency, resultSetHoldability); }
Example #13
Source File: KylinJdbcFactory.java From kylin with Apache License 2.0 | 4 votes |
@Override public AvaticaStatement newStatement(AvaticaConnection connection, StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return new KylinStatement((KylinConnection) connection, h, resultSetType, resultSetConcurrency, resultSetHoldability); }
Example #14
Source File: KylinPreparedStatement.java From kylin with Apache License 2.0 | 4 votes |
protected KylinPreparedStatement(AvaticaConnection connection, StatementHandle h, Signature signature, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { super(connection, h, signature, resultSetType, resultSetConcurrency, resultSetHoldability); if (this.handle.signature == null) this.handle.signature = signature; }
Example #15
Source File: DremioConnectionImpl.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override protected AvaticaStatement lookupStatement(StatementHandle h) throws SQLException { return super.lookupStatement(h); }
Example #16
Source File: DremioStatementImpl.java From dremio-oss with Apache License 2.0 | 4 votes |
DremioStatementImpl(DremioConnectionImpl connection, StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) { super(connection, h, resultSetType, resultSetConcurrency, resultSetHoldability); this.connection = connection; connection.openStatementsRegistry.addStatement(this); }
Example #17
Source File: MissingResultsException.java From calcite-avatica with Apache License 2.0 | 4 votes |
public StatementHandle getHandle() { return handle; }
Example #18
Source File: MissingResultsException.java From calcite-avatica with Apache License 2.0 | 4 votes |
public MissingResultsException(StatementHandle handle) { this.handle = handle; }
Example #19
Source File: NoSuchStatementException.java From calcite-avatica with Apache License 2.0 | 4 votes |
public StatementHandle getStatementHandle() { return stmtHandle; }
Example #20
Source File: NoSuchStatementException.java From calcite-avatica with Apache License 2.0 | 4 votes |
public NoSuchStatementException(StatementHandle stmtHandle) { this.stmtHandle = stmtHandle; }
Example #21
Source File: KylinStatement.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
protected KylinStatement(AvaticaConnection connection, StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) { super(connection, h, resultSetType, resultSetConcurrency, resultSetHoldability); }
Example #22
Source File: KylinJdbcFactory.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Override public AvaticaPreparedStatement newPreparedStatement(AvaticaConnection connection, StatementHandle h, Signature signature, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return new KylinPreparedStatement((KylinConnection) connection, h, signature, resultSetType, resultSetConcurrency, resultSetHoldability); }
Example #23
Source File: KylinJdbcFactory.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Override public AvaticaStatement newStatement(AvaticaConnection connection, StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return new KylinStatement((KylinConnection) connection, h, resultSetType, resultSetConcurrency, resultSetHoldability); }