Class JdbcStatement

  • JdbcStatement represents a JDBC Statement and mirrors the documentation found injava.sql.Statement.

  • It includes methods for executing various SQL commands likeaddBatch,execute,executeQuery, andexecuteUpdate.

  • Methods are available to manage the statement's state, such ascancel,clearBatch,clearWarnings, andclose.

  • You can retrieve information about the statement and its results using methods likegetWarnings,getResultSet, andgetUpdateCount.

  • Several methods allow setting properties likesetFetchSize,setMaxRows, andsetQueryTimeout.

JdbcStatement

A JDBCStatement. For documentation of this class, seejava.sql.Statement.

Methods

MethodReturn typeBrief description
addBatch(sql)voidFor documentation of this method, seejava.sql.Statement#addBatch(String).
cancel()voidFor documentation of this method, seejava.sql.Statement#cancel().
clearBatch()voidFor documentation of this method, seejava.sql.Statement#clearBatch().
clearWarnings()voidFor documentation of this method, seejava.sql.Statement#clearWarnings().
close()voidFor documentation of this method, seejava.sql.Statement#close().
execute(sql)BooleanFor documentation of this method, seejava.sql.Statement#execute(String).
execute(sql, autoGeneratedKeys)BooleanFor documentation of this method, seejava.sql.Statement#execute(String, int).
execute(sql, columnIndexes)BooleanFor documentation of this method, seejava.sql.Statement#execute(String, int[]).
execute(sql, columnNames)BooleanFor documentation of this method, seejava.sql.Statement#execute(String, String[]).
executeBatch()Integer[]For documentation of this method, seejava.sql.Statement#executeBatch().
executeQuery(sql)JdbcResultSetFor documentation of this method, seejava.sql.Statement#executeQuery(String).
executeUpdate(sql)IntegerFor documentation of this method, seejava.sql.Statement#executeUpdate(String).
executeUpdate(sql, autoGeneratedKeys)IntegerFor documentation of this method, seejava.sql.Statement#executeUpdate(String, int).
executeUpdate(sql, columnIndexes)IntegerFor documentation of this method, seejava.sql.Statement#executeUpdate(String, int[]).
executeUpdate(sql, columnNames)IntegerFor documentation of this method, seejava.sql.Statement#executeUpdate(String, String[]).
getConnection()JdbcConnectionFor documentation of this method, seejava.sql.Statement#getConnection().
getFetchDirection()IntegerFor documentation of this method, seejava.sql.Statement#getFetchDirection().
getFetchSize()IntegerFor documentation of this method, seejava.sql.Statement#getFetchSize().
getGeneratedKeys()JdbcResultSetFor documentation of this method, seejava.sql.Statement#getGeneratedKeys().
getMaxFieldSize()IntegerFor documentation of this method, seejava.sql.Statement#getMaxFieldSize().
getMaxRows()IntegerFor documentation of this method, seejava.sql.Statement#getMaxRows().
getMoreResults()BooleanFor documentation of this method, seejava.sql.Statement#getMoreResults().
getMoreResults(current)BooleanFor documentation of this method, seejava.sql.Statement#getMoreResults(int).
getQueryTimeout()IntegerFor documentation of this method, seejava.sql.Statement#getQueryTimeout().
getResultSet()JdbcResultSetFor documentation of this method, seejava.sql.Statement#getResultSet().
getResultSetConcurrency()IntegerFor documentation of this method, seejava.sql.Statement#getResultSetConcurrency().
getResultSetHoldability()IntegerFor documentation of this method, seejava.sql.Statement#getResultSetHoldability().
getResultSetType()IntegerFor documentation of this method, seejava.sql.Statement#getResultSetType().
getUpdateCount()IntegerFor documentation of this method, seejava.sql.Statement#getUpdateCount().
getWarnings()String[]For documentation of this method, seejava.sql.Statement#getWarnings().
isClosed()BooleanFor documentation of this method, seejava.sql.Statement#isClosed().
isPoolable()BooleanFor documentation of this method, seejava.sql.Statement#isPoolable().
setCursorName(name)voidFor documentation of this method, seejava.sql.Statement#setCursorName(String).
setEscapeProcessing(enable)voidFor documentation of this method, seejava.sql.Statement#setEscapeProcessing(boolean).
setFetchDirection(direction)voidFor documentation of this method, seejava.sql.Statement#setFetchDirection(int).
setFetchSize(rows)voidFor documentation of this method, seejava.sql.Statement#setFetchSize(int).
setMaxFieldSize(max)voidFor documentation of this method, seejava.sql.Statement#setMaxFieldSize(int).
setMaxRows(max)voidFor documentation of this method, seejava.sql.Statement#setMaxRows(int).
setPoolable(poolable)voidFor documentation of this method, seejava.sql.Statement#setPoolable(boolean).
setQueryTimeout(seconds)voidFor documentation of this method, seejava.sql.Statement#setQueryTimeout(int).

Detailed documentation

addBatch(sql)

For documentation of this method, seejava.sql.Statement#addBatch(String).

Parameters

NameTypeDescription
sqlStringThe SQL command to add to this statement, typically an SQLINSERT orUPDATE.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

cancel()

For documentation of this method, seejava.sql.Statement#cancel().

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

clearBatch()

For documentation of this method, seejava.sql.Statement#clearBatch().

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

clearWarnings()

For documentation of this method, seejava.sql.Statement#clearWarnings().

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

close()

For documentation of this method, seejava.sql.Statement#close().


execute(sql)

For documentation of this method, seejava.sql.Statement#execute(String).

Parameters

NameTypeDescription
sqlStringThe SQL statement to execute.

Return

Booleantrue if the first result is a result set;false if it is an update count or if there are no results.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

execute(sql, autoGeneratedKeys)

For documentation of this method, seejava.sql.Statement#execute(String, int).

Parameters

NameTypeDescription
sqlStringThe SQL statement to execute.
autoGeneratedKeysIntegerA flag that indicates whether auto-generated keys are made available for future retrieval; eitherJdbc.Statement.RETURN_GENERATED_KEYS orJdbc.Statement.NO_GENERATED_KEYS.

Return

Booleantrue if the first result is a result set;false if it is an update count or if there are no results.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

execute(sql, columnIndexes)

For documentation of this method, seejava.sql.Statement#execute(String, int[]).

Parameters

NameTypeDescription
sqlStringThe SQL statement to execute.
columnIndexesInteger[]The column indices in the whose auto-generated keys are made available for future retrieval.

Return

Booleantrue if the first result is a result set;false if it is an update count or if there are no results.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

execute(sql, columnNames)

For documentation of this method, seejava.sql.Statement#execute(String, String[]).

Parameters

NameTypeDescription
sqlStringThe SQL statement to execute.
columnNamesString[]The names of columns in the whose auto-generated keys are made available for future retrieval.

Return

Booleantrue if the first result is a result set;false if it is an update count or if there are no results.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

executeBatch()

For documentation of this method, seejava.sql.Statement#executeBatch().

Return

Integer[] — The update counts for each command in the batch, using the same order in which commands were added to the batch.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

executeQuery(sql)

For documentation of this method, seejava.sql.Statement#executeQuery(String).

Parameters

NameTypeDescription
sqlStringThe SQL statement to execute, typically a staticSELECT.

Return

JdbcResultSet — A result set containing the results of the execution. This is nevernull.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

executeUpdate(sql)

For documentation of this method, seejava.sql.Statement#executeUpdate(String).

Parameters

NameTypeDescription
sqlStringThe SQL Data Manipulation Language statement to execute (such asINSERT,UPDATE, orDELETE), or else a statement that returns nothing (such as a DDL statement).

Return

Integer — Either the row count for for Data Manipulation Language statements, or 0 for statements that return nothing.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

executeUpdate(sql, autoGeneratedKeys)

For documentation of this method, seejava.sql.Statement#executeUpdate(String, int).

Parameters

NameTypeDescription
sqlStringThe SQL Data Manipulation Language statement to execute (such asINSERT,UPDATE, orDELETE), or else a statement that returns nothing (such as a DDL statement).
autoGeneratedKeysIntegerA flag that indicates whether auto-generated keys are made available for future retrieval; eitherJdbc.Statement.RETURN_GENERATED_KEYS orJdbc.Statement.NO_GENERATED_KEYS.

Return

Integer — Either the row count for for Data Manipulation Language statements, or 0 for statements that return nothing.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

executeUpdate(sql, columnIndexes)

For documentation of this method, seejava.sql.Statement#executeUpdate(String, int[]).

Parameters

NameTypeDescription
sqlStringThe SQL Data Manipulation Language statement to execute (such asINSERT,UPDATE, orDELETE), or else a statement that returns nothing (such as a DDL statement).
columnIndexesInteger[]The column indices in the whose auto-generated keys are made available for future retrieval.

Return

Integer — Either the row count for for Data Manipulation Language statements, or 0 for statements that return nothing.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

executeUpdate(sql, columnNames)

For documentation of this method, seejava.sql.Statement#executeUpdate(String, String[]).

Parameters

NameTypeDescription
sqlStringThe SQL Data Manipulation Language statement to execute (such asINSERT,UPDATE, orDELETE), or else a statement that returns nothing (such as a DDL statement).
columnNamesString[]The names of columns in the whose auto-generated keys are made available for future retrieval.

Return

Integer — Either the row count for for Data Manipulation Language statements, or 0 for statements that return nothing.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getConnection()

For documentation of this method, seejava.sql.Statement#getConnection().

Return

JdbcConnection — The connection that produced this statement.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getFetchDirection()

For documentation of this method, seejava.sql.Statement#getFetchDirection().

Return

Integer — The default direction for result sets generated by this statement, which is eitherJdbc.ResultSet.FETCH_FORWARD orJdbc.ResultSet.FETCH_REVERSE.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getFetchSize()

For documentation of this method, seejava.sql.Statement#getFetchSize().

Return

Integer — The default row fetch size for result sets generated from this statement.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getGeneratedKeys()

For documentation of this method, seejava.sql.Statement#getGeneratedKeys().

Return

JdbcResultSet — A result set containing the auto-generated keys generated by the execution of this statement.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getMaxFieldSize()

For documentation of this method, seejava.sql.Statement#getMaxFieldSize().

Return

Integer — The current column byte size limit for columns storing character and binary values; a value of zero indictates no limit.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getMaxRows()

For documentation of this method, seejava.sql.Statement#getMaxRows().

Return

Integer — The current maximum number of rows for a result set produced by this statement; a value of 0 indicates no limit.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getMoreResults()

For documentation of this method, seejava.sql.Statement#getMoreResults().

Return

Booleantrue if the next result is a result set;false otherwise.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getMoreResults(current)

For documentation of this method, seejava.sql.Statement#getMoreResults(int).

Parameters

NameTypeDescription
currentIntegerA flag that indicates what happens to current result sets when retrieved. This value is one ofJdbc.Statement.CLOSE_CURRENT_RESULT,Jdbc.Statement.KEEP_CURRENT_RESULT, orJdbc.Statement.CLOSE_ALL_RESULTS.

Return

Booleantrue if the next result is a result set;false otherwise.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getQueryTimeout()

For documentation of this method, seejava.sql.Statement#getQueryTimeout().

Return

Integer — The current query timeout in seconds; a value of zero indicates no timeout.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getResultSet()

For documentation of this method, seejava.sql.Statement#getResultSet().

Return

JdbcResultSet — The current result set, ornull if the result is an update count or there are no more results.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getResultSetConcurrency()

For documentation of this method, seejava.sql.Statement#getResultSetConcurrency().

Return

Integer — The result set concurrency for result sets generated from this statement, which is eitherJdbc.ResultSet.CONCUR_READ_ONLY orJdbc.ResultSet.CONCUR_UPDATABLE.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getResultSetHoldability()

For documentation of this method, seejava.sql.Statement#getResultSetHoldability().

Return

Integer — The result set holdability, which is eitherJdbc.ResultSet.HOLD_CURSORS_OVER_COMMIT orJdbc.ResultSet.CLOSE_CURSORS_AT_COMMIT.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getResultSetType()

For documentation of this method, seejava.sql.Statement#getResultSetType().

Return

Integer — The result set type for result sets generated from this statement, which isJdbc.ResultSet.TYPE_FORWARD_ONLY,Jdbc.ResultSet.TYPE_SCROLL_INSENSITIVE, orJdbc.ResultSet.TYPE_SCROLL_INSENSITIVE.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getUpdateCount()

For documentation of this method, seejava.sql.Statement#getUpdateCount().

Return

Integer — The current result as an update count, or -1 if the current result is a result set or if there are no more results.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

getWarnings()

For documentation of this method, seejava.sql.Statement#getWarnings().

Return

String[] — The current set of warnings, ornull if there are no warnings.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

isClosed()

For documentation of this method, seejava.sql.Statement#isClosed().

Return

Booleantrue if this statement is closed;false otherwise.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

isPoolable()

For documentation of this method, seejava.sql.Statement#isPoolable().

Return

Booleantrue if this statement is poolable;false otherwise.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

setCursorName(name)

For documentation of this method, seejava.sql.Statement#setCursorName(String).

Parameters

NameTypeDescription
nameStringThe new cursor name, which must be unique within a connection.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

setEscapeProcessing(enable)

For documentation of this method, seejava.sql.Statement#setEscapeProcessing(boolean).

Parameters

NameTypeDescription
enableBooleanIftrue, escape processing is enabled; otherwise it is disabled.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

setFetchDirection(direction)

For documentation of this method, seejava.sql.Statement#setFetchDirection(int).

Parameters

NameTypeDescription
directionIntegerThe specified direction to set, which is eitherJdbc.ResultSet.FETCH_FORWARD orJdbc.ResultSet.FETCH_REVERSE.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

setFetchSize(rows)

For documentation of this method, seejava.sql.Statement#setFetchSize(int).

Parameters

NameTypeDescription
rowsIntegerThe number of rows to fetch.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

setMaxFieldSize(max)

For documentation of this method, seejava.sql.Statement#setMaxFieldSize(int).

Parameters

NameTypeDescription
maxIntegerThe new column byte size limit; a value of zero indicates no limit.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

setMaxRows(max)

For documentation of this method, seejava.sql.Statement#setMaxRows(int).

Parameters

NameTypeDescription
maxIntegerThe maximum number of rows a result set generated by this statement can have. A value of 0 indicates no limit.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

setPoolable(poolable)

For documentation of this method, seejava.sql.Statement#setPoolable(boolean).

Parameters

NameTypeDescription
poolableBooleanIftrue, requests that this statement be pooled; otherwise requests it not be pooled.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

setQueryTimeout(seconds)

For documentation of this method, seejava.sql.Statement#setQueryTimeout(int).

Parameters

NameTypeDescription
secondsIntegerThe new query timeout in seconds; a value of 0 indicates no timeout.

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/script.external_request

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

Last updated 2025-12-11 UTC.