Class BigQueryStatement (2.58.0)

public class BigQueryStatement extends BigQueryNoOpsStatement

An implementation of java.sql.Statement for executing BigQuery SQL statement and returning the results it produces. See Also: BigQueryConnection#createStatement, ResultSet

Inheritance

Object > com.google.cloud.bigquery.jdbc.BigQueryNoOpsStatement > BigQueryStatement

Static Fields

queryTaskExecutor

protected static ExecutorService queryTaskExecutor
Field Value
Type Description
ExecutorService

Constructors

BigQueryStatement(BigQueryConnection connection)

public BigQueryStatement(BigQueryConnection connection)
Parameter
Name Description
connection BigQueryConnection

Fields

batchQueries

protected List<String> batchQueries
Field Value
Type Description
List<String>

cancelLock

protected Object cancelLock
Field Value
Type Description
Object

closeOnCompletion

protected boolean closeOnCompletion
Field Value
Type Description
boolean

connection

protected BigQueryConnection connection
Field Value
Type Description
BigQueryConnection

currentJobIdIndex

protected int currentJobIdIndex
Field Value
Type Description
int

currentResultSet

protected ResultSet currentResultSet
Field Value
Type Description
ResultSet

currentUpdateCount

protected long currentUpdateCount
Field Value
Type Description
long

isCanceled

protected boolean isCanceled
Field Value
Type Description
boolean

isClosed

protected boolean isClosed
Field Value
Type Description
boolean

jobIds

protected List<JobId> jobIds
Field Value
Type Description
List<JobId>

maxFieldSize

protected int maxFieldSize
Field Value
Type Description
int

maxRows

protected int maxRows
Field Value
Type Description
int

parentJobId

protected BigQueryStatement.JobIdWrapper parentJobId
Field Value
Type Description
com.google.cloud.bigquery.jdbc.BigQueryStatement.JobIdWrapper

poolable

protected boolean poolable
Field Value
Type Description
boolean

queryTimeout

protected int queryTimeout
Field Value
Type Description
int

warning

protected SQLWarning warning
Field Value
Type Description
SQLWarning

Methods

<T>unwrap(Class<T> iface)

public T <T>unwrap(Class<T> iface)
Parameter
Name Description
iface Class<T>
Returns
Type Description
T
Overrides
com.google.cloud.bigquery.jdbc.BigQueryNoOpsStatement.<T>unwrap(java.lang.Class<T>)
Exceptions
Type Description
SQLException

addBatch(String sql)

public void addBatch(String sql)
Parameter
Name Description
sql String
Exceptions
Type Description
SQLException

cancel()

public void cancel()

Cancels this Statement object, the running threads, and BigQuery jobs.

Exceptions
Type Description
SQLException

if a BigQuery access error occurs or this method is called on a closed Statement

clearBatch()

public void clearBatch()

clearWarnings()

public void clearWarnings()

close()

public void close()

Releases this Statement's BigQuery and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. These resources include the ResultSet object, batch queries, job IDs, and BigQuery connection

Calling the method close on a Statement object that is already closed has no effect.

Exceptions
Type Description
SQLException

if a BigQuery access error occurs

closeOnCompletion()

public void closeOnCompletion()

execute(String sql)

public boolean execute(String sql)
Parameter
Name Description
sql String
Returns
Type Description
boolean
Exceptions
Type Description
SQLException

executeBatch()

public int[] executeBatch()
Returns
Type Description
int[]
Exceptions
Type Description
SQLException

executeLargeUpdate(String sql)

public long executeLargeUpdate(String sql)
Parameter
Name Description
sql String
Returns
Type Description
long
Exceptions
Type Description
SQLException

executeQuery(String sql)

public ResultSet executeQuery(String sql)

This method executes a BigQuery SQL query, return a single ResultSet object.

Example of running a query:

Connection connection = DriverManager.getConnection(CONNECTION_URL); Statement bigQueryStatement = bigQueryConnection.createStatement(); ResultSet result = bigQueryStatement.executeQuery(QUERY);

See Also: java.sql.Statement#executeQuery(String)

Parameter
Name Description
sql String

BigQuery SQL query

Returns
Type Description
ResultSet

ResultSet containing the output of the query

Exceptions
Type Description
SQLException

if a BigQuery access error occurs, this method is called on a closed Statement, the given SQL statement produces multiple or no result sets.

executeUpdate(String sql)

public int executeUpdate(String sql)
Parameter
Name Description
sql String
Returns
Type Description
int
Exceptions
Type Description
SQLException

getConnection()

public Connection getConnection()
Returns
Type Description
Connection

getExtraLabels()

public Map<String,String> getExtraLabels()

Gets the extra labels for this statement.

Returns
Type Description
Map<String,String>

A map of the extra labels.

getFetchDirection()

public int getFetchDirection()
Returns
Type Description
int

getFetchSize()

public int getFetchSize()
Returns
Type Description
int

getLargeUpdateCount()

public long getLargeUpdateCount()
Returns
Type Description
long

getMaxFieldSize()

public int getMaxFieldSize()
Returns
Type Description
int

getMaxRows()

public int getMaxRows()
Returns
Type Description
int

getMoreResults()

public boolean getMoreResults()
Returns
Type Description
boolean
Exceptions
Type Description
SQLException

getMoreResults(int current)

public boolean getMoreResults(int current)
Parameter
Name Description
current int
Returns
Type Description
boolean
Exceptions
Type Description
SQLException

getQueryTimeout()

public int getQueryTimeout()
Returns
Type Description
int

getResultSet()

public ResultSet getResultSet()
Returns
Type Description
ResultSet

getResultSetConcurrency()

public int getResultSetConcurrency()
Returns
Type Description
int

getResultSetHoldability()

public int getResultSetHoldability()
Returns
Type Description
int

getResultSetType()

public int getResultSetType()
Returns
Type Description
int

getUpdateCount()

public int getUpdateCount()
Returns
Type Description
int

getWarnings()

public SQLWarning getWarnings()
Returns
Type Description
SQLWarning

hasMoreResults()

public boolean hasMoreResults()
Returns
Type Description
boolean

isCloseOnCompletion()

public boolean isCloseOnCompletion()
Returns
Type Description
boolean

isClosed()

public boolean isClosed()
Returns
Type Description
boolean

isPoolable()

public boolean isPoolable()
Returns
Type Description
boolean

isWrapperFor(Class<?> iface)

public boolean isWrapperFor(Class<?> iface)
Parameter
Name Description
iface Class<?>
Returns
Type Description
boolean
Overrides
com.google.cloud.bigquery.jdbc.BigQueryNoOpsStatement.isWrapperFor(java.lang.Class<?>)

logQueryExecutionStart(String sql)

protected void logQueryExecutionStart(String sql)
Parameter
Name Description
sql String

setEscapeProcessing(boolean enable)

public void setEscapeProcessing(boolean enable)
Parameter
Name Description
enable boolean

setExtraLabels(Map<String,String> extraLabels)

public void setExtraLabels(Map<String,String> extraLabels)

Sets the extra labels for this statement.

Parameter
Name Description
extraLabels Map<String,String>

A map of the extra labels.

setFetchDirection(int direction)

public void setFetchDirection(int direction)
Parameter
Name Description
direction int
Exceptions
Type Description
SQLException

setFetchSize(int rows)

public void setFetchSize(int rows)
Parameter
Name Description
rows int

setMaxFieldSize(int max)

public void setMaxFieldSize(int max)
Parameter
Name Description
max int

setMaxRows(int max)

public void setMaxRows(int max)
Parameter
Name Description
max int

setPoolable(boolean poolable)

public void setPoolable(boolean poolable)
Parameter
Name Description
poolable boolean

setQueryTimeout(int seconds)

public void setQueryTimeout(int seconds)
Parameter
Name Description
seconds int