Class IntermediateStatement (0.15.0)

publicclass IntermediateStatement

Data type to store simple SQL statement with designated metadata. Allows manipulation of statement, such as execution, termination, etc. Represented as an intermediate representation for statements which does not belong directly to Postgres, Spanner, etc.

Inheritance

java.lang.Object > IntermediateStatement

Static Fields

PARSER

protectedstaticfinalPostgreSQLStatementParserPARSER
Field Value
Type Description

Constructors

IntermediateStatement(ConnectionHandler connectionHandler, OptionsMetadata options, AbstractStatementParser.ParsedStatement parsedStatement, Statement originalStatement)

protectedIntermediateStatement(ConnectionHandlerconnectionHandler,OptionsMetadataoptions,AbstractStatementParser.ParsedStatementparsedStatement,StatementoriginalStatement)
Parameters
Name Description
connectionHandler ConnectionHandler
options OptionsMetadata
parsedStatement ParsedStatement
originalStatement com.google.cloud.spanner.Statement

IntermediateStatement(OptionsMetadata options, AbstractStatementParser.ParsedStatement parsedStatement, Statement originalStatement, ConnectionHandler connectionHandler)

publicIntermediateStatement(OptionsMetadataoptions,AbstractStatementParser.ParsedStatementparsedStatement,StatementoriginalStatement,ConnectionHandlerconnectionHandler)
Parameters
Name Description
options OptionsMetadata
parsedStatement ParsedStatement
originalStatement com.google.cloud.spanner.Statement
connectionHandler ConnectionHandler

Fields

command

protectedfinalStringcommand
Field Value
Type Description

commandTag

protectedStringcommandTag
Field Value
Type Description

connection

protectedfinalConnectionconnection
Field Value
Type Description

connectionHandler

protectedfinalConnectionHandlerconnectionHandler
Field Value
Type Description

described

protectedbooleandescribed
Field Value
Type Description

exception

protectedPGExceptionexception
Field Value
Type Description

executed

protectedbooleanexecuted
Field Value
Type Description

futureStatementResult

protectedFuture<StatementResult>futureStatementResult
Field Value
Type Description

hasMoreData

protectedbooleanhasMoreData
Field Value
Type Description

options

protectedfinalOptionsMetadataoptions
Field Value
Type Description

originalStatement

protectedfinalStatementoriginalStatement
Field Value
Type Description
com.google.cloud.spanner.Statement

outputStream

protectedfinalDataOutputStreamoutputStream
Field Value
Type Description

parsedStatement

protectedfinalAbstractStatementParser.ParsedStatementparsedStatement
Field Value
Type Description

statementResult

protectedStatementResultstatementResult
Field Value
Type Description

Methods

close()

publicvoidclose()

Cleanly close the statement. Does nothing if the statement has not been executed or has no result.

Exceptions
Type Description
Exception

if closing fails server-side.

containsResultSet()

publicbooleancontainsResultSet()
Returns
Type Description
boolean

True if this is a select statement, false otherwise.

createDataRowResponse(Converter converter)

publicWireOutputcreateDataRowResponse(Converterconverter)
Parameter
Name Description
converter Converter
Returns
Type Description

createResultPrefix(ResultSet resultSet)

publicWireOutput[]createResultPrefix(ResultSetresultSet)
Parameter
Name Description
resultSet com.google.cloud.spanner.ResultSet
Returns
Type Description

createResultSuffix()

publicWireOutput[]createResultSuffix()
Returns
Type Description

describe()

publicDescribeResultdescribe()

Moreso meant for inherited classes, allows one to call describe on a statement. Since raw statements cannot be described, throw an error.

Returns
Type Description

describeAsync(BackendConnection backendConnection)

publicFuture<StatementResult>describeAsync(BackendConnectionbackendConnection)
Parameter
Name Description
backendConnection BackendConnection
Returns
Type Description

executeAsync(BackendConnection backendConnection)

publicvoidexecuteAsync(BackendConnectionbackendConnection)
Parameter
Name Description
backendConnection BackendConnection

getCommand()

publicStringgetCommand()
Returns
Type Description
String

the extracted command (first word) from the SQL statement.

getCommandTag()

publicStringgetCommandTag()
Returns
Type Description
String

the extracted command (first word) from the really executed SQL statement.

getConnection()

publicConnectiongetConnection()
Returns
Type Description

getConnectionHandler()

publicConnectionHandlergetConnectionHandler()
Returns
Type Description

getException()

publicPGExceptiongetException()

Returns any execution exception registered for this statement.

Returns
Type Description

getResultFormatCode(int index)

publicshortgetResultFormatCode(intindex)

Moreso intended for inherited classes (prepared statements et al) which allow the setting of result format codes. Here we dafault to string.

Parameter
Name Description
index int
Returns
Type Description

getSql()

publicStringgetSql()
Returns
Type Description

getStatement()

publicStringgetStatement()
Returns
Type Description

getStatementResult()

publicStatementResultgetStatementResult()

Returns the result of this statement as a StatementResult. Fails if the result is not yet available.

Returns
Type Description

getStatementType()

publicAbstractStatementParser.StatementTypegetStatementType()
Returns
Type Description

getUpdateCount()

publiclonggetUpdateCount()
Returns
Type Description
long

The number of items that were modified by this execution for DML. 0 for DDL and -1 for QUERY. Fails if the result is not yet available.

getUpdateCount(IntermediateStatement.ResultNotReadyBehavior resultNotReadyBehavior)

publiclonggetUpdateCount(IntermediateStatement.ResultNotReadyBehaviorresultNotReadyBehavior)
Parameter
Name Description
Returns
Type Description
long

The number of items that were modified by this execution for DML. 0 for DDL and -1 for QUERY. Will block or fail depending on the given ResultNotReadyBehavior if the result is not yet available.

handleExecutionException(PGException exception)

publicvoidhandleExecutionException(PGExceptionexception)

Clean up and save metadata when an exception occurs.

Parameter
Name Description
exception PGException

The exception to store.

hasException()

publicbooleanhasException()
Returns
Type Description
boolean

True if at some point in execution an exception was thrown. Fails if execution has not yet finished.

hasException(IntermediateStatement.ResultNotReadyBehavior resultNotReadyBehavior)

publicbooleanhasException(IntermediateStatement.ResultNotReadyBehaviorresultNotReadyBehavior)
Parameter
Name Description
Returns
Type Description
boolean

True if at some point in execution an exception was thrown. Fails or blocks depending on the given ResultNotReadyBehavior if execution has not yet finished.

isBound()

publicbooleanisBound()

Whether this is a bound statement (i.e.: ready to execute)

Returns
Type Description
boolean

True if bound, false otherwise.

isDescribed()

publicbooleanisDescribed()
Returns
Type Description

isExecuted()

publicbooleanisExecuted()
Returns
Type Description
boolean

True if this statement was executed, False otherwise.

isHasMoreData()

publicbooleanisHasMoreData()
Returns
Type Description
boolean

True if only a subset of the available data has been returned.

setFutureStatementResult(Future<StatementResult> result)

protectedvoidsetFutureStatementResult(Future<StatementResult>result)
Parameter
Name Description

setHasMoreData(boolean hasMoreData)

publicvoidsetHasMoreData(booleanhasMoreData)
Parameter
Name Description
hasMoreData boolean

setStatementResult(StatementResult statementResult)

publicvoidsetStatementResult(StatementResultstatementResult)
Parameter
Name Description
statementResult StatementResult

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月30日 UTC.