public class CloudSpannerStatement extends AbstractCloudSpannerFetcher
| Modifier and Type | Class and Description |
|---|---|
class |
CloudSpannerStatement.CustomDriverStatement |
| Modifier and Type | Field and Description |
|---|---|
protected int |
currentResultSetIndex |
protected List<ResultSet> |
currentResultSets |
protected int |
lastUpdateCount |
protected static String |
NO_MUTATIONS_IN_READ_ONLY_MODE_EXCEPTION |
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO| Constructor and Description |
|---|
CloudSpannerStatement(CloudSpannerConnection connection,
com.google.cloud.spanner.DatabaseClient dbClient) |
| Modifier and Type | Method and Description |
|---|---|
void |
addBatch(String sql) |
void |
cancel() |
protected void |
checkClosed() |
void |
clearBatch() |
void |
clearWarnings() |
void |
close() |
void |
closeOnCompletion() |
protected String |
createInsertSelectOnDuplicateKeyUpdateStatement(net.sf.jsqlparser.statement.update.Update update)
Transform the given UPDATE-statement into an "INSERT INTO TAB1 (...) SELECT ...
|
protected void |
determineForceSingleUseReadContext(net.sf.jsqlparser.statement.select.Select select)
Determines whether the given sql statement must be executed in a single use read context.
|
boolean |
execute(String sql) |
boolean |
execute(String sql,
int autoGeneratedKeys) |
boolean |
execute(String sql,
int[] columnIndexes) |
boolean |
execute(String sql,
String[] columnNames) |
int[] |
executeBatch() |
protected void |
executeDDL(List<String> ddl) |
protected int |
executeDDL(String ddl) |
ResultSet |
executeQuery(String sql) |
int |
executeUpdate(String sql) |
int |
executeUpdate(String sql,
int autoGeneratedKeys) |
int |
executeUpdate(String sql,
int[] columnIndexes) |
int |
executeUpdate(String sql,
String[] columnNames) |
protected String |
formatDDLStatement(String sql)
Does some formatting to DDL statements that might have been generated by standard SQL
generators to make it compatible with Google Cloud Spanner.
|
List<String> |
getBatch() |
protected com.google.cloud.spanner.BatchReadOnlyTransaction |
getBatchReadOnlyTransaction() |
CloudSpannerConnection |
getConnection() |
nl.topicus.jdbc.statement.CloudSpannerStatement.BatchMode |
getCurrentBatchMode()
Batching of DML and DDL statements together is not supported.
|
protected CloudSpannerStatement.CustomDriverStatement |
getCustomDriverStatement(String[] sqlTokens)
Checks if a sql statement is a custom statement only recognized by this driver
|
ResultSet |
getGeneratedKeys() |
int |
getMaxFieldSize() |
int |
getMaxRows() |
boolean |
getMoreResults() |
boolean |
getMoreResults(int current) |
int |
getQueryTimeout() |
protected com.google.cloud.spanner.ReadContext |
getReadContext() |
ResultSet |
getResultSet() |
int |
getResultSetConcurrency() |
int |
getResultSetHoldability() |
int |
getResultSetType() |
protected String[] |
getTokens(String sql)
Remove comments from the given sql string and split it into parts based on all space characters
|
protected String[] |
getTokens(String sql,
int limit)
Remove comments from the given sql string and split it into parts based on all space characters
|
int |
getUpdateCount() |
SQLWarning |
getWarnings() |
boolean |
isClosed() |
boolean |
isCloseOnCompletion() |
protected boolean |
isDDLStatement(String[] sqlTokens)
Do a quick check if this SQL statement is a DDL statement
|
boolean |
isForceSingleUseReadContext() |
boolean |
isPoolable() |
protected boolean |
isSelectStatement(String[] sqlTokens) |
protected List<com.google.cloud.spanner.Partition> |
partitionQuery(com.google.cloud.spanner.Statement statement) |
protected String |
quoteIdentifier(String identifier) |
protected String |
removeComments(String sql) |
protected String |
sanitizeSQL(String sql) |
void |
setCursorName(String name) |
void |
setEscapeProcessing(boolean enable) |
void |
setForceSingleUseReadContext(boolean forceSingleUseReadContext) |
void |
setMaxFieldSize(int max) |
void |
setMaxRows(int max) |
void |
setPoolable(boolean poolable) |
void |
setQueryTimeout(int seconds) |
protected String |
unquoteIdentifier(String identifier) |
protected long |
writeMutations(nl.topicus.jdbc.statement.Mutations mutations) |
getFetchDirection, getFetchSize, setFetchDirection, setFetchSizeextractColumnType, getClassName, getClassName, getGoogleTypeName, isWrapperFor, unwrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexecuteLargeBatch, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, getFetchDirection, getFetchSize, getLargeMaxRows, getLargeUpdateCount, setFetchDirection, setFetchSize, setLargeMaxRowsisWrapperFor, unwrapprotected int currentResultSetIndex
protected int lastUpdateCount
protected static final String NO_MUTATIONS_IN_READ_ONLY_MODE_EXCEPTION
public CloudSpannerStatement(CloudSpannerConnection connection, com.google.cloud.spanner.DatabaseClient dbClient)
protected String formatDDLStatement(String sql)
sql - The sql to formatpublic nl.topicus.jdbc.statement.CloudSpannerStatement.BatchMode getCurrentBatchMode()
public List<String> getBatch()
executeBatch() is called.public void addBatch(String sql) throws SQLException
SQLExceptionpublic void clearBatch()
throws SQLException
SQLExceptionpublic int[] executeBatch()
throws SQLException
SQLExceptionprotected int executeDDL(String ddl) throws SQLException
SQLExceptionprotected void executeDDL(List<String> ddl) throws SQLException
SQLExceptionpublic ResultSet executeQuery(String sql) throws SQLException
SQLExceptionpublic int executeUpdate(String sql) throws SQLException
SQLExceptionpublic boolean execute(String sql) throws SQLException
SQLExceptionprotected boolean isDDLStatement(String[] sqlTokens)
sqlTokens - The statement to checkprotected String[] getTokens(String sql)
sql - The sql string to split into tokensprotected String[] getTokens(String sql, int limit)
sql - The sql statement to break into partslimit - The maximum number of times the pattern should be appliedprotected boolean isSelectStatement(String[] sqlTokens)
protected CloudSpannerStatement.CustomDriverStatement getCustomDriverStatement(String[] sqlTokens)
sqlTokens - The statement to checkpublic ResultSet getResultSet() throws SQLException
SQLExceptionpublic int getUpdateCount()
throws SQLException
SQLExceptionpublic boolean getMoreResults()
throws SQLException
SQLExceptionpublic boolean getMoreResults(int current)
throws SQLException
SQLExceptionpublic int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
SQLExceptionpublic int executeUpdate(String sql, int[] columnIndexes) throws SQLException
SQLExceptionpublic int executeUpdate(String sql, String[] columnNames) throws SQLException
SQLExceptionpublic boolean execute(String sql, int autoGeneratedKeys) throws SQLException
SQLExceptionpublic boolean execute(String sql, int[] columnIndexes) throws SQLException
SQLExceptionpublic boolean execute(String sql, String[] columnNames) throws SQLException
SQLExceptionpublic ResultSet getGeneratedKeys() throws SQLException
SQLExceptionprotected String createInsertSelectOnDuplicateKeyUpdateStatement(net.sf.jsqlparser.statement.update.Update update) throws SQLException
update - The UPDATE-statementSQLException - if a database exception occurs while getting the table meta data or if the
statement tries to update the primary key valueprotected void determineForceSingleUseReadContext(net.sf.jsqlparser.statement.select.Select select)
forceSingleUseReadContext to true if necessary.select - The sql statement to be examined.public boolean isForceSingleUseReadContext()
public void setForceSingleUseReadContext(boolean forceSingleUseReadContext)
protected com.google.cloud.spanner.ReadContext getReadContext()
throws SQLException
SQLExceptionprotected List<com.google.cloud.spanner.Partition> partitionQuery(com.google.cloud.spanner.Statement statement)
protected com.google.cloud.spanner.BatchReadOnlyTransaction getBatchReadOnlyTransaction()
protected long writeMutations(nl.topicus.jdbc.statement.Mutations mutations)
throws SQLException
SQLExceptionpublic boolean isClosed()
throws SQLException
isClosed in interface StatementSQLExceptionpublic void close()
throws SQLException
close in interface AutoCloseableclose in interface StatementSQLExceptionprotected void checkClosed()
throws SQLException
SQLExceptionpublic int getMaxFieldSize()
throws SQLException
getMaxFieldSize in interface StatementSQLExceptionpublic void setMaxFieldSize(int max)
throws SQLException
setMaxFieldSize in interface StatementSQLExceptionpublic int getMaxRows()
throws SQLException
getMaxRows in interface StatementSQLExceptionpublic void setMaxRows(int max)
throws SQLException
setMaxRows in interface StatementSQLExceptionpublic void setEscapeProcessing(boolean enable)
throws SQLException
setEscapeProcessing in interface StatementSQLExceptionpublic int getQueryTimeout()
throws SQLException
getQueryTimeout in interface StatementSQLExceptionpublic void setQueryTimeout(int seconds)
throws SQLException
setQueryTimeout in interface StatementSQLExceptionpublic void cancel()
throws SQLException
cancel in interface StatementSQLExceptionpublic SQLWarning getWarnings() throws SQLException
getWarnings in interface StatementSQLExceptionpublic void clearWarnings()
throws SQLException
clearWarnings in interface StatementSQLExceptionpublic void setCursorName(String name) throws SQLException
setCursorName in interface StatementSQLExceptionpublic int getResultSetConcurrency()
throws SQLException
getResultSetConcurrency in interface StatementSQLExceptionpublic int getResultSetType()
throws SQLException
getResultSetType in interface StatementSQLExceptionpublic CloudSpannerConnection getConnection() throws SQLException
getConnection in interface StatementSQLExceptionpublic int getResultSetHoldability()
throws SQLException
getResultSetHoldability in interface StatementSQLExceptionpublic void setPoolable(boolean poolable)
throws SQLException
setPoolable in interface StatementSQLExceptionpublic boolean isPoolable()
throws SQLException
isPoolable in interface StatementSQLExceptionpublic void closeOnCompletion()
throws SQLException
closeOnCompletion in interface StatementSQLExceptionpublic boolean isCloseOnCompletion()
throws SQLException
isCloseOnCompletion in interface StatementSQLExceptionCopyright © 2018. All rights reserved.