public boolean getAutoCommit() throws SQLException { if (meta.connectionSync(handle, new ConnectionPropertiesImpl()).isAutoCommit() == null) setAutoCommit(true); return super.getAutoCommit(); }
protected AvaticaStatement(AvaticaConnection connection, Meta.StatementHandle h, int resultSetType, int resultSetConcurrency, int resultSetHoldability, Meta.Signature signature) { this.connection = Objects.requireNonNull(connection); this.resultSetType = resultSetType; this.resultSetConcurrency = resultSetConcurrency; this.resultSetHoldability = resultSetHoldability; this.signature = signature; this.closed = false; if (h == null) { final Meta.ConnectionHandle ch = connection.handle; h = connection.meta.createStatement(ch); } connection.statementMap.put(h.id, this); this.handle = h; }
public void commit() throws SQLException { meta.commit(handle); }
public CloseConnectionResponse apply(CloseConnectionRequest request) { final Meta.ConnectionHandle ch = new Meta.ConnectionHandle(request.connectionId); meta.closeConnection(ch); return new CloseConnectionResponse(serverLevelRpcMetadata); }
public CloseStatementResponse apply(CloseStatementRequest request) { final Meta.StatementHandle h = new Meta.StatementHandle( request.connectionId, request.statementId, null); meta.closeStatement(h); return new CloseStatementResponse(serverLevelRpcMetadata); }
public ExecuteResponse apply(ExecuteRequest request) { try { final Meta.ExecuteResult executeResult = meta.execute(request.statementHandle, request.parameterValues, request.maxRowCount); final List<ResultSetResponse> results = new ArrayList<>(); for (Meta.MetaResultSet metaResultSet : executeResult.resultSets) { results.add(toResponse(metaResultSet)); } return new ExecuteResponse(results, false, serverLevelRpcMetadata); } catch (NoSuchStatementException e) { return new ExecuteResponse(null, true, serverLevelRpcMetadata); } }
private List<List<Object>> list2(Meta.MetaResultSet resultSet) { final Meta.StatementHandle h = new Meta.StatementHandle( resultSet.connectionId, resultSet.statementId, null); final List<TypedValue> parameterValues = Collections.emptyList(); final Iterable<Object> iterable = meta.createIterable(h, null, resultSet.signature, parameterValues, resultSet.firstFrame); final List<List<Object>> list = new ArrayList<>(); return MetaImpl.collect(resultSet.signature.cursorFactory, iterable, list); }
public ResultSet call() { try { return connection.createResultSet( connection.meta.getAttributes(connection.handle, catalog, pat(schemaPattern), pat(typeNamePattern), pat(attributeNamePattern)), new QueryState(MetaDataOperation.GET_ATTRIBUTES, catalog, schemaPattern, typeNamePattern, attributeNamePattern)); } catch (SQLException e) { throw new RuntimeException(e); } } });
public ResultSet call() { try { return connection.createResultSet( connection.meta.getBestRowIdentifier(connection.handle, catalog, schema, table, scope, nullable), new QueryState(MetaDataOperation.GET_BEST_ROW_IDENTIFIER, catalog, table, scope, nullable)); } catch (SQLException e) { throw new RuntimeException(e); } } });
public FetchResponse apply(FetchRequest request) { final Meta.StatementHandle h = new Meta.StatementHandle( request.connectionId, request.statementId, null); try { final Meta.Frame frame = meta.fetch(h, request.offset, request.fetchMaxRowCount); return new FetchResponse(frame, false, false, serverLevelRpcMetadata); } catch (NullPointerException | NoSuchStatementException e) { // The Statement doesn't exist anymore, bubble up this information return new FetchResponse(null, true, true, serverLevelRpcMetadata); } catch (MissingResultsException e) { return new FetchResponse(null, false, true, serverLevelRpcMetadata); } }
protected void resetStatement() { // Invalidate the old statement connection.statementMap.remove(handle.id); // Get a new one final Meta.ConnectionHandle ch = new Meta.ConnectionHandle(connection.id); Meta.StatementHandle h = connection.meta.createStatement(ch); // Cache it in the connection connection.statementMap.put(h.id, this); // Update the local state and try again this.handle = h; }
public void commit() throws SQLException { checkOpen(); meta.commit(handle); }
public CloseConnectionResponse apply(CloseConnectionRequest request) { final Meta.ConnectionHandle ch = new Meta.ConnectionHandle(request.connectionId); meta.closeConnection(ch); return new CloseConnectionResponse(serverLevelRpcMetadata); }
public CloseStatementResponse apply(CloseStatementRequest request) { final Meta.StatementHandle h = new Meta.StatementHandle( request.connectionId, request.statementId, null); meta.closeStatement(h); return new CloseStatementResponse(serverLevelRpcMetadata); }
public ExecuteResponse apply(ExecuteRequest request) { try (final Context ignore = executeTimer.start()) { try { final Meta.ExecuteResult executeResult = meta.execute(request.statementHandle, request.parameterValues, AvaticaUtils.toSaturatedInt(request.maxRowCount)); final List<ResultSetResponse> results = new ArrayList<>(executeResult.resultSets.size()); for (Meta.MetaResultSet metaResultSet : executeResult.resultSets) { results.add(toResponse(metaResultSet)); } return new ExecuteResponse(results, false, serverLevelRpcMetadata); } catch (NoSuchStatementException e) { return new ExecuteResponse(null, true, serverLevelRpcMetadata); } } }
/** * Executes this result set. (Not a JDBC method.) * * <p>Note that execute cannot occur in the constructor, because the * constructor occurs while the statement is locked, to make sure that * execute/cancel don't happen at the same time.</p> * * @see org.apache.calcite.avatica.AvaticaConnection.Trojan#execute(AvaticaResultSet) * * @throws SQLException if execute fails for some reason. */ protected AvaticaResultSet execute() throws SQLException { final Iterable<Object> iterable1 = statement.connection.meta.createIterable(statement.handle, state, signature, Collections.<TypedValue>emptyList(), firstFrame); this.cursor = MetaImpl.createCursor(signature.cursorFactory, iterable1); this.accessorList = cursor.createAccessors(columnMetaDataList, localCalendar, this); this.row = 0; this.beforeFirst = true; this.afterLast = false; return this; }
public ResultSet call() { try { return connection.createResultSet( connection.meta.getAttributes(connection.handle, catalog, pat(schemaPattern), pat(typeNamePattern), pat(attributeNamePattern)), new QueryState(MetaDataOperation.GET_ATTRIBUTES, catalog, schemaPattern, typeNamePattern, attributeNamePattern)); } catch (SQLException e) { throw new RuntimeException(e); } } });
public ResultSet call() { try { return connection.createResultSet( connection.meta.getBestRowIdentifier(connection.handle, catalog, schema, table, scope, nullable), new QueryState(MetaDataOperation.GET_BEST_ROW_IDENTIFIER, catalog, table, scope, nullable)); } catch (SQLException e) { throw new RuntimeException(e); } } });
public FetchResponse apply(FetchRequest request) { final Meta.StatementHandle h = new Meta.StatementHandle( request.connectionId, request.statementId, null); try { final Meta.Frame frame = meta.fetch(h, request.offset, request.fetchMaxRowCount); return new FetchResponse(frame, false, false, serverLevelRpcMetadata); } catch (NullPointerException | NoSuchStatementException e) { // The Statement doesn't exist anymore, bubble up this information return new FetchResponse(null, true, true, serverLevelRpcMetadata); } catch (MissingResultsException e) { return new FetchResponse(null, false, true, serverLevelRpcMetadata); } }
public boolean isReadOnly() throws SQLException { if (meta.connectionSync(handle, new ConnectionPropertiesImpl()).isReadOnly() == null) setReadOnly(true); return super.isReadOnly(); }