|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.postgresql.jdbc.PgStatement
public class PgStatement
| Nested Class Summary | |
|---|---|
class |
PgStatement.StatementResultHandler
ResultHandler implementations for updates, queries, and either-or. |
| Field Summary | |
|---|---|
protected ArrayList<ParameterList> |
batchParameters
|
protected ArrayList<Query> |
batchStatements
|
protected int |
concurrency
|
protected BaseConnection |
connection
|
protected int |
fetchdirection
|
protected int |
fetchSize
Number of rows to get in a batch. |
protected ResultWrapper |
firstUnclosedResult
The first unclosed result. |
protected ResultWrapper |
generatedKeys
Results returned by a statement that wants generated keys. |
protected boolean |
isClosed
|
protected Query |
lastSimpleQuery
|
protected SQLWarning |
lastWarning
The last warning of the warning chain. |
protected int |
m_prepareThreshold
|
protected int |
maxfieldSize
|
protected int |
maxrows
Maximum number of rows to return, 0 = unlimited |
protected boolean |
replaceProcessingEnabled
|
protected ResultWrapper |
result
The current results. |
protected int |
resultsettype
|
protected int |
timeout
Timeout (in milliseconds) for a query |
boolean |
wantsGeneratedKeysAlways
Was this PreparedStatement created to return generated keys for every execution? |
protected boolean |
wantsGeneratedKeysOnce
Does the caller of execute/executeUpdate want generated keys for this execution? |
protected SQLWarning |
warnings
The warnings chain. |
| Fields inherited from interface org.postgresql.PGStatement |
|---|
DATE_NEGATIVE_INFINITY, DATE_NEGATIVE_SMALLER_INFINITY, DATE_POSITIVE_INFINITY, DATE_POSITIVE_SMALLER_INFINITY |
| Fields inherited from interface java.sql.Statement |
|---|
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO |
| Method Summary | ||
|---|---|---|
void |
addBatch(String p_sql)
|
|
void |
addWarning(SQLWarning warn)
This adds a warning to the warning chain. |
|
void |
cancel()
|
|
protected void |
checkClosed()
|
|
protected void |
checkCompletion()
|
|
void |
clearBatch()
|
|
void |
clearWarnings()
|
|
void |
close()
Note: even though Statement is automatically closed when it is garbage
collected, it is better to close it explicitly to lower resource consumption. |
|
protected void |
closeForNextExecution()
|
|
void |
closeOnCompletion()
|
|
protected BatchResultHandler |
createBatchHandler(int[] updateCounts,
Query[] queries,
ParameterList[] parameterLists)
|
|
ResultSet |
createDriverResultSet(Field[] fields,
List<byte[][]> tuples)
Create a synthetic resultset from data provided by the driver. |
|
ResultSet |
createResultSet(Query originalQuery,
Field[] fields,
List<byte[][]> tuples,
ResultCursor cursor)
Create a resultset from data retrieved from the server. |
|
protected static String |
escapeFunction(String functionName,
String args,
boolean stdStrings)
generate sql for escaped functions |
|
protected void |
execute(Query queryToExecute,
ParameterList queryParameters,
int flags)
|
|
boolean |
execute(String p_sql)
|
|
boolean |
execute(String sql,
int autoGeneratedKeys)
|
|
boolean |
execute(String sql,
int[] columnIndexes)
|
|
boolean |
execute(String sql,
String[] columnNames)
|
|
int[] |
executeBatch()
|
|
long[] |
executeLargeBatch()
|
|
long |
executeLargeUpdate()
|
|
long |
executeLargeUpdate(String sql)
|
|
long |
executeLargeUpdate(String sql,
int autoGeneratedKeys)
|
|
long |
executeLargeUpdate(String sql,
int[] columnIndexes)
|
|
long |
executeLargeUpdate(String sql,
String[] columnNames)
|
|
ResultSet |
executeQuery(String p_sql)
|
|
int |
executeUpdate(String p_sql)
|
|
int |
executeUpdate(String sql,
int autoGeneratedKeys)
|
|
int |
executeUpdate(String sql,
int[] columnIndexes)
|
|
int |
executeUpdate(String sql,
String[] columnNames)
|
|
boolean |
executeWithFlags(int flags)
Execute a prepared query, passing additional query flags. |
|
boolean |
executeWithFlags(String p_sql,
int flags)
Execute a query, passing additional query flags. |
|
Connection |
getConnection()
|
|
int |
getFetchDirection()
|
|
String |
getFetchingCursorName()
|
|
int |
getFetchSize()
|
|
protected boolean |
getForceBinaryTransfer()
|
|
ResultSet |
getGeneratedKeys()
|
|
long |
getLargeMaxRows()
|
|
long |
getLargeUpdateCount()
|
|
long |
getLastOID()
Returns the Last inserted/updated oid. |
|
int |
getMaxFieldSize()
|
|
int |
getMaxRows()
|
|
boolean |
getMoreResults()
|
|
boolean |
getMoreResults(int current)
|
|
Logger |
getParentLogger()
|
|
BaseConnection |
getPGConnection()
|
|
int |
getPrepareThreshold()
Gets the server-side prepare reuse threshold in use for this statement. |
|
int |
getQueryTimeout()
|
|
int |
getQueryTimeoutMs()
The queryTimeout limit is the number of milliseconds the driver will wait for a Statement to execute. |
|
ResultSet |
getResultSet()
|
|
int |
getResultSetConcurrency()
|
|
int |
getResultSetHoldability()
|
|
int |
getResultSetType()
|
|
int |
getUpdateCount()
|
|
SQLWarning |
getWarnings()
|
|
boolean |
isClosed()
|
|
boolean |
isCloseOnCompletion()
|
|
protected boolean |
isOneShotQuery(Query query)
Returns true if query is unlikely to be reused |
|
boolean |
isPoolable()
|
|
boolean |
isUseServerPrepare()
Checks if this statement will be executed as a server-prepared statement. |
|
boolean |
isWrapperFor(Class<?> iface)
|
|
protected static int |
parseSql(String p_sql,
int i,
StringBuilder newsql,
boolean stopOnComma,
boolean stdStrings)
parse the given sql from index i, appending it to the given buffer until we hit an unmatched right parentheses or end of string. |
|
void |
setCursorName(String name)
|
|
void |
setEscapeProcessing(boolean enable)
|
|
void |
setFetchDirection(int direction)
|
|
void |
setFetchSize(int rows)
|
|
void |
setLargeMaxRows(long max)
|
|
void |
setMaxFieldSize(int max)
|
|
void |
setMaxRows(int max)
|
|
void |
setPoolable(boolean poolable)
|
|
void |
setPrepareThreshold(int newThreshold)
Sets the reuse threshold for using server-prepared statements. |
|
void |
setQueryTimeout(int seconds)
|
|
void |
setQueryTimeoutMs(int millis)
Sets the queryTimeout limit |
|
void |
setUseServerPrepare(boolean flag)
Turn on the use of prepared statements in the server (server side prepared statements are unrelated to jdbc PreparedStatements) As of build 302, this method is equivalent to setPrepareThreshold(1). |
|
|
unwrap(Class<T> iface)
|
|
protected boolean |
wantsHoldableResultSet()
|
|
protected boolean |
wantsScrollableResultSet()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ArrayList<Query> batchStatements
protected ArrayList<ParameterList> batchParameters
protected final int resultsettype
protected final int concurrency
protected int fetchdirection
protected boolean wantsGeneratedKeysOnce
public boolean wantsGeneratedKeysAlways
protected final BaseConnection connection
protected SQLWarning warnings
protected SQLWarning lastWarning
protected int maxrows
protected int fetchSize
protected int timeout
protected boolean replaceProcessingEnabled
protected ResultWrapper result
protected ResultWrapper firstUnclosedResult
protected ResultWrapper generatedKeys
protected Query lastSimpleQuery
protected int m_prepareThreshold
protected int maxfieldSize
protected boolean isClosed
| Method Detail |
|---|
public ResultSet createResultSet(Query originalQuery,
Field[] fields,
List<byte[][]> tuples,
ResultCursor cursor)
throws SQLException
BaseStatement
createResultSet in interface BaseStatementoriginalQuery - the query that generated this resultset; used when dealing with updateable
resultsetsfields - the column metadata for the resultsettuples - the resultset datacursor - the cursor to use to retrieve more data from the server; if null, no additional
data is present.
SQLException - if something goes wrongpublic BaseConnection getPGConnection()
public String getFetchingCursorName()
public int getFetchSize()
getFetchSize in interface Statementprotected boolean wantsScrollableResultSet()
protected boolean wantsHoldableResultSet()
public ResultSet executeQuery(String p_sql)
throws SQLException
executeQuery in interface StatementSQLException
public int executeUpdate(String p_sql)
throws SQLException
executeUpdate in interface StatementSQLException
public boolean execute(String p_sql)
throws SQLException
execute in interface StatementSQLException
public boolean executeWithFlags(String p_sql,
int flags)
throws SQLException
BaseStatement
executeWithFlags in interface BaseStatementp_sql - the query to executeflags - additional QueryExecutor flags for execution; these are bitwise-ORed into
the default flags.
SQLException - if something goes wrong.
public boolean executeWithFlags(int flags)
throws SQLException
BaseStatement
executeWithFlags in interface BaseStatementflags - additional QueryExecutor flags for execution; these are bitwise-ORed into
the default flags.
SQLException - if something goes wrong.
protected void closeForNextExecution()
throws SQLException
SQLExceptionprotected boolean isOneShotQuery(Query query)
query - to check (null if current query)
protected void execute(Query queryToExecute,
ParameterList queryParameters,
int flags)
throws SQLException
SQLException
public void setCursorName(String name)
throws SQLException
setCursorName in interface StatementSQLException
public int getUpdateCount()
throws SQLException
getUpdateCount in interface StatementSQLException
public boolean getMoreResults()
throws SQLException
getMoreResults in interface StatementSQLException
public int getMaxRows()
throws SQLException
getMaxRows in interface StatementSQLException
public void setMaxRows(int max)
throws SQLException
setMaxRows in interface StatementSQLException
public void setEscapeProcessing(boolean enable)
throws SQLException
setEscapeProcessing in interface StatementSQLException
public int getQueryTimeout()
throws SQLException
getQueryTimeout in interface StatementSQLException
public void setQueryTimeout(int seconds)
throws SQLException
setQueryTimeout in interface StatementSQLException
public int getQueryTimeoutMs()
throws SQLException
SQLException - if a database access error occurs
public void setQueryTimeoutMs(int millis)
throws SQLException
millis - - the new query timeout limit in milliseconds
SQLException - if a database access error occurspublic void addWarning(SQLWarning warn)
warn - warning to add
public SQLWarning getWarnings()
throws SQLException
getWarnings in interface StatementSQLException
public int getMaxFieldSize()
throws SQLException
getMaxFieldSize in interface StatementSQLException
public void setMaxFieldSize(int max)
throws SQLException
setMaxFieldSize in interface StatementSQLException
public void clearWarnings()
throws SQLException
clearWarnings in interface StatementSQLException
public ResultSet getResultSet()
throws SQLException
getResultSet in interface StatementSQLException
public void close()
throws SQLException
Statement is automatically closed when it is garbage
collected, it is better to close it explicitly to lower resource consumption.
close in interface StatementSQLException
protected static int parseSql(String p_sql,
int i,
StringBuilder newsql,
boolean stopOnComma,
boolean stdStrings)
throws SQLException
p_sql - the original query texti - starting position for replacingnewsql - where to write the replaced outputstopOnComma - should we stop after hitting the first comma in sql text?stdStrings - whether standard_conforming_strings is on
SQLException - if given SQL is wrong
protected static String escapeFunction(String functionName,
String args,
boolean stdStrings)
throws SQLException
functionName - the escaped function nameargs - the arguments for this functionstdStrings - whether standard_conforming_strings is on
SQLException - if something goes wrong
public long getLastOID()
throws SQLException
PGStatement
getLastOID in interface PGStatementSQLException - if something goes wrong
public void setPrepareThreshold(int newThreshold)
throws SQLException
PGStatement
If threshold is a non-zero value N, the Nth and subsequent reuses of a
PreparedStatement will use server-side prepare.
If threshold is zero, server-side prepare will not be used.
The reuse threshold is only used by PreparedStatement and CallableStatement objects; it is ignored for plain Statements.
setPrepareThreshold in interface PGStatementnewThreshold - the new threshold for this statement
SQLException - if an exception occurs while changing the thresholdpublic int getPrepareThreshold()
PGStatement
getPrepareThreshold in interface PGStatementPGStatement.setPrepareThreshold(int)
public void setUseServerPrepare(boolean flag)
throws SQLException
PGStatementsetPrepareThreshold(1).
setUseServerPrepare in interface PGStatementflag - use server prepare
SQLException - if something goes wrongpublic boolean isUseServerPrepare()
PGStatementtrue indicates that the next execution of the statement will be done as a
server-prepared statement, assuming the underlying protocol supports it.
isUseServerPrepare in interface PGStatement
protected void checkClosed()
throws SQLException
SQLException
public void addBatch(String p_sql)
throws SQLException
addBatch in interface StatementSQLException
public void clearBatch()
throws SQLException
clearBatch in interface StatementSQLException
protected BatchResultHandler createBatchHandler(int[] updateCounts,
Query[] queries,
ParameterList[] parameterLists)
public int[] executeBatch()
throws SQLException
executeBatch in interface StatementSQLException
public void cancel()
throws SQLException
cancel in interface StatementSQLException
public Connection getConnection()
throws SQLException
getConnection in interface StatementSQLExceptionpublic int getFetchDirection()
getFetchDirection in interface Statementpublic int getResultSetConcurrency()
getResultSetConcurrency in interface Statementpublic int getResultSetType()
getResultSetType in interface Statement
public void setFetchDirection(int direction)
throws SQLException
setFetchDirection in interface StatementSQLException
public void setFetchSize(int rows)
throws SQLException
setFetchSize in interface StatementSQLExceptionprotected boolean getForceBinaryTransfer()
public long getLargeUpdateCount()
throws SQLException
SQLException
public void setLargeMaxRows(long max)
throws SQLException
SQLException
public long getLargeMaxRows()
throws SQLException
SQLException
public long[] executeLargeBatch()
throws SQLException
SQLException
public long executeLargeUpdate(String sql)
throws SQLException
SQLException
public long executeLargeUpdate(String sql,
int autoGeneratedKeys)
throws SQLException
SQLException
public long executeLargeUpdate(String sql,
int[] columnIndexes)
throws SQLException
SQLException
public long executeLargeUpdate(String sql,
String[] columnNames)
throws SQLException
SQLException
public long executeLargeUpdate()
throws SQLException
SQLException
public boolean isClosed()
throws SQLException
isClosed in interface StatementSQLException
public void setPoolable(boolean poolable)
throws SQLException
setPoolable in interface StatementSQLException
public boolean isPoolable()
throws SQLException
isPoolable in interface StatementSQLException
public boolean isWrapperFor(Class<?> iface)
throws SQLException
isWrapperFor in interface WrapperSQLException
public <T> T unwrap(Class<T> iface)
throws SQLException
unwrap in interface WrapperSQLException
public Logger getParentLogger()
throws SQLFeatureNotSupportedException
SQLFeatureNotSupportedException
public void closeOnCompletion()
throws SQLException
SQLException
public boolean isCloseOnCompletion()
throws SQLException
SQLException
protected void checkCompletion()
throws SQLException
SQLException
public boolean getMoreResults(int current)
throws SQLException
getMoreResults in interface StatementSQLException
public ResultSet getGeneratedKeys()
throws SQLException
getGeneratedKeys in interface StatementSQLException
public int executeUpdate(String sql,
int autoGeneratedKeys)
throws SQLException
executeUpdate in interface StatementSQLException
public int executeUpdate(String sql,
int[] columnIndexes)
throws SQLException
executeUpdate in interface StatementSQLException
public int executeUpdate(String sql,
String[] columnNames)
throws SQLException
executeUpdate in interface StatementSQLException
public boolean execute(String sql,
int autoGeneratedKeys)
throws SQLException
execute in interface StatementSQLException
public boolean execute(String sql,
int[] columnIndexes)
throws SQLException
execute in interface StatementSQLException
public boolean execute(String sql,
String[] columnNames)
throws SQLException
execute in interface StatementSQLException
public int getResultSetHoldability()
throws SQLException
getResultSetHoldability in interface StatementSQLException
public ResultSet createDriverResultSet(Field[] fields,
List<byte[][]> tuples)
throws SQLException
BaseStatement
createDriverResultSet in interface BaseStatementfields - the column metadata for the resultsettuples - the resultset data
SQLException - if something goes wrong
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||