|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.postgresql.jdbc.PgConnection
public class PgConnection
| Nested Class Summary | |
|---|---|
class |
PgConnection.AbortCommand
|
| Field Summary | |
|---|---|
protected int |
defaultFetchSize
Default fetch size for statement |
protected boolean |
forcebinary
|
protected DatabaseMetaData |
metadata
|
protected int |
prepareThreshold
|
protected Map<String,Class<?>> |
typemap
The current type mappings |
| Fields inherited from interface java.sql.Connection |
|---|
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
| Constructor Summary | |
|---|---|
PgConnection(HostSpec[] hostSpecs,
String user,
String database,
Properties info,
String url)
|
|
| Method Summary | ||
|---|---|---|
protected void |
abort()
|
|
void |
abort(Executor executor)
|
|
void |
addDataType(String type,
Class<? extends PGobject> klass)
This allows client code to add a handler for one of org.postgresql's more unique data types. |
|
void |
addDataType(String type,
String name)
This allows client code to add a handler for one of org.postgresql's more unique data types. |
|
void |
addTimerTask(TimerTask timerTask,
long milliSeconds)
Schedule a TimerTask for later execution. |
|
void |
addWarning(SQLWarning warn)
This adds a warning to the warning chain. |
|
boolean |
binaryTransferSend(int oid)
Returns true if value for the given oid should be sent using binary transfer. |
|
void |
cancelQuery()
Cancel the current query executing on this connection. |
|
protected void |
checkClosed()
|
|
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. |
|
void |
commit()
|
|
Array |
createArrayOf(String typeName,
Object[] elements)
|
|
Blob |
createBlob()
|
|
Clob |
createClob()
|
|
NClob |
createNClob()
|
|
|
createQueryObject(Class<T> ifc)
|
|
SQLXML |
createSQLXML()
|
|
Statement |
createStatement()
|
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
|
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
|
|
Struct |
createStruct(String typeName,
Object[] attributes)
|
|
protected TypeInfo |
createTypeInfo(BaseConnection conn,
int unknownLength)
|
|
byte[] |
encodeString(String str)
Encode a string using the database's client_encoding (usually UTF8, but can vary on older server versions). |
|
String |
escapeIdentifier(String identifier)
Return the given string suitably quoted to be used as an identifier in an SQL statement string. |
|
String |
escapeLiteral(String literal)
Return the given string suitably quoted to be used as a string literal in an SQL statement string. |
|
String |
escapeString(String str)
Escapes a string for use as string-literal within an SQL command. |
|
ResultSet |
execSQLQuery(String s)
Execute a SQL query that returns a single resultset. |
|
ResultSet |
execSQLQuery(String s,
int resultSetType,
int resultSetConcurrency)
|
|
void |
execSQLUpdate(String s)
Execute a SQL query that does not return results. |
|
protected void |
finalize()
Overrides finalize(). |
|
boolean |
getAutoCommit()
|
|
int |
getBackendPID()
Return the process ID (PID) of the backend server process handling this connection. |
|
String |
getCatalog()
|
|
Properties |
getClientInfo()
|
|
String |
getClientInfo(String name)
|
|
CopyManager |
getCopyAPI()
This returns the COPY API for the current connection. |
|
String |
getCursorName()
getCursorName gets the cursor name. |
|
String |
getDBVersionNumber()
Get server version number |
|
int |
getDefaultFetchSize()
Get the default fetch size for statements created from this connection |
|
Encoding |
getEncoding()
|
|
Fastpath |
getFastpathAPI()
This returns the Fastpath API for the current connection. |
|
boolean |
getForceBinary()
|
|
int |
getHoldability()
|
|
protected String |
getIsolationLevelName(int level)
|
|
LargeObjectManager |
getLargeObjectAPI()
This returns the LargeObject API for the current connection. |
|
Logger |
getLogger()
|
|
DatabaseMetaData |
getMetaData()
|
|
int |
getNetworkTimeout()
|
|
PGNotification[] |
getNotifications()
This method returns any notifications that have been received since the last call to this method. |
|
Object |
getObject(String type,
String value,
byte[] byteValue)
Construct and return an appropriate object for the given type and value. |
|
int |
getPrepareThreshold()
Get the default server-side prepare reuse threshold for statements created from this connection. |
|
int |
getProtocolVersion()
|
|
QueryExecutor |
getQueryExecutor()
Get the QueryExecutor implementation for this connection. |
|
String |
getSchema()
|
|
int |
getServerMajorVersion()
Get server major version |
|
int |
getServerMinorVersion()
Get server minor version |
|
boolean |
getStandardConformingStrings()
Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules. |
|
boolean |
getStringVarcharFlag()
|
|
TimestampUtils |
getTimestampUtils()
|
|
int |
getTransactionIsolation()
|
|
int |
getTransactionState()
Get the current transaction state of this connection. |
|
TypeInfo |
getTypeInfo()
|
|
Map<String,Class<?>> |
getTypeMap()
|
|
String |
getURL()
We are required to bring back certain information by the DatabaseMetaData class. |
|
String |
getUserName()
Method getUserName() brings back the User Name (again, we saved it) |
|
SQLWarning |
getWarnings()
|
|
boolean |
haveMinimumCompatibleVersion(int ver)
Check if we should use driver behaviour introduced in a particular driver version. |
|
boolean |
haveMinimumCompatibleVersion(String ver)
Check if we should use driver behaviour introduced in a particular driver version. |
|
boolean |
haveMinimumCompatibleVersion(Version ver)
Check if we should use driver behaviour introduced in a particular driver version. |
|
boolean |
haveMinimumServerVersion(int ver)
Check if we have at least a particular server version. |
|
boolean |
haveMinimumServerVersion(String ver)
Check if we have at least a particular server version. |
|
boolean |
haveMinimumServerVersion(Version ver)
Check if we have at least a particular server version. |
|
boolean |
isClosed()
|
|
boolean |
isColumnSanitiserDisabled()
Return whether to disable column name sanitation. |
|
boolean |
isReadOnly()
|
|
boolean |
isValid(int timeout)
|
|
boolean |
isWrapperFor(Class<?> iface)
|
|
protected Array |
makeArray(int oid,
String fieldString)
|
|
protected Blob |
makeBlob(long oid)
|
|
protected Clob |
makeClob(long oid)
|
|
protected SQLXML |
makeSQLXML()
|
|
String |
nativeSQL(String sql)
|
|
CallableStatement |
prepareCall(String sql)
|
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
|
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
|
|
PreparedStatement |
prepareStatement(String sql)
|
|
PreparedStatement |
prepareStatement(String sql,
int autoGeneratedKeys)
|
|
PreparedStatement |
prepareStatement(String sql,
int[] columnIndexes)
|
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
|
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
|
|
PreparedStatement |
prepareStatement(String sql,
String[] columnNames)
|
|
void |
purgeTimerTasks()
Invoke purge() on the underlying shared Timer so that internal resources will be released. |
|
void |
releaseSavepoint(Savepoint savepoint)
|
|
void |
rollback()
|
|
void |
rollback(Savepoint savepoint)
|
|
void |
setAutoCommit(boolean autoCommit)
|
|
void |
setCatalog(String catalog)
|
|
void |
setClientInfo(Properties properties)
|
|
void |
setClientInfo(String name,
String value)
|
|
void |
setCursorName(String cursor)
In SQL, a result table can be retrieved through a cursor that is named. |
|
void |
setDefaultFetchSize(int fetchSize)
Set the default fetch size for statements created from this connection |
|
void |
setDisableColumnSanitiser(boolean disableColumnSanitiser)
|
|
void |
setForceBinary(boolean newValue)
|
|
void |
setHoldability(int holdability)
|
|
void |
setNetworkTimeout(Executor executor,
int milliseconds)
|
|
void |
setPrepareThreshold(int newThreshold)
Set the default statement reuse threshold before enabling server-side prepare. |
|
void |
setReadOnly(boolean readOnly)
|
|
Savepoint |
setSavepoint()
|
|
Savepoint |
setSavepoint(String name)
|
|
void |
setSchema(String schema)
|
|
void |
setTransactionIsolation(int level)
|
|
void |
setTypeMap(Map<String,Class<?>> map)
|
|
void |
setTypeMapImpl(Map<String,Class<?>> map)
|
|
|
unwrap(Class<T> iface)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int prepareThreshold
protected int defaultFetchSize
PGProperty.DEFAULT_ROW_FETCH_SIZEprotected boolean forcebinary
protected Map<String,Class<?>> typemap
protected DatabaseMetaData metadata
| Constructor Detail |
|---|
public PgConnection(HostSpec[] hostSpecs,
String user,
String database,
Properties info,
String url)
throws SQLException
SQLException| Method Detail |
|---|
public TimestampUtils getTimestampUtils()
getTimestampUtils in interface BaseConnection
public Statement createStatement()
throws SQLException
createStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql)
throws SQLException
prepareStatement in interface ConnectionSQLException
public CallableStatement prepareCall(String sql)
throws SQLException
prepareCall in interface ConnectionSQLException
public Map<String,Class<?>> getTypeMap()
throws SQLException
getTypeMap in interface ConnectionSQLExceptionpublic QueryExecutor getQueryExecutor()
BaseConnection
getQueryExecutor in interface BaseConnectionpublic void addWarning(SQLWarning warn)
warn - warning to add
public ResultSet execSQLQuery(String s)
throws SQLException
BaseConnection
execSQLQuery in interface BaseConnections - the query to execute
SQLException - if something goes wrong.
public ResultSet execSQLQuery(String s,
int resultSetType,
int resultSetConcurrency)
throws SQLException
execSQLQuery in interface BaseConnectionSQLException
public void execSQLUpdate(String s)
throws SQLException
BaseConnection
execSQLUpdate in interface BaseConnections - the query to execute
SQLException - if something goes wrong.
public void setCursorName(String cursor)
throws SQLException
We do not support positioned update/delete, so this is a no-op.
cursor - the cursor name
SQLException - if a database access error occurs
public String getCursorName()
throws SQLException
SQLException - if a database access error occurs
public String getURL()
throws SQLException
Method getURL() brings back the URL (good job we saved it)
SQLException - just in case...
public String getUserName()
throws SQLException
SQLException - just in case...
public Fastpath getFastpathAPI()
throws SQLException
PGConnection
getFastpathAPI in interface PGConnectionSQLException - if something wrong happens
public LargeObjectManager getLargeObjectAPI()
throws SQLException
PGConnection
getLargeObjectAPI in interface PGConnectionSQLException - if something wrong happens
public Object getObject(String type,
String value,
byte[] byteValue)
throws SQLException
BaseConnectionPGConnection.addDataType(String, Class) and
PGConnection.addDataType(String, String).
If no class is registered as handling the given type, then a generic
PGobject instance is returned.
getObject in interface BaseConnectiontype - the backend typenamevalue - the type-specific string representation of the valuebyteValue - the type-specific binary representation of the value
SQLException - if something goes wrong
protected TypeInfo createTypeInfo(BaseConnection conn,
int unknownLength)
public TypeInfo getTypeInfo()
getTypeInfo in interface BaseConnection
public void addDataType(String type,
String name)
PGConnectionaddDataType(type, Class.forName(name)).
addDataType in interface PGConnectiontype - JDBC type namename - class name
public void addDataType(String type,
Class<? extends PGobject> klass)
throws SQLException
PGConnectionNOTE: This is not part of JDBC, but an extension.
The best way to use this is as follows:
...
((org.postgresql.PGConnection)myconn).addDataType("mytype", my.class.name.class);
...
where myconn is an open Connection to org.postgresql.
The handling class must extend org.postgresql.util.PGobject
addDataType in interface PGConnectiontype - the PostgreSQL type to registerklass - the class implementing the Java representation of the type; this class must
implement PGobject).
SQLException - if klass does not implement
PGobject).PGobject
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 ConnectionSQLException
public String nativeSQL(String sql)
throws SQLException
nativeSQL in interface ConnectionSQLException
public SQLWarning getWarnings()
throws SQLException
getWarnings in interface ConnectionSQLException
public void clearWarnings()
throws SQLException
clearWarnings in interface ConnectionSQLException
public void setReadOnly(boolean readOnly)
throws SQLException
setReadOnly in interface ConnectionSQLException
public boolean isReadOnly()
throws SQLException
isReadOnly in interface ConnectionSQLException
public void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit in interface ConnectionSQLException
public boolean getAutoCommit()
throws SQLException
getAutoCommit in interface ConnectionSQLException
public void commit()
throws SQLException
commit in interface ConnectionSQLException
protected void checkClosed()
throws SQLException
SQLException
public void rollback()
throws SQLException
rollback in interface ConnectionSQLExceptionpublic int getTransactionState()
BaseConnection
getTransactionState in interface BaseConnection
public int getTransactionIsolation()
throws SQLException
getTransactionIsolation in interface ConnectionSQLException
public void setTransactionIsolation(int level)
throws SQLException
setTransactionIsolation in interface ConnectionSQLExceptionprotected String getIsolationLevelName(int level)
public void setCatalog(String catalog)
throws SQLException
setCatalog in interface ConnectionSQLException
public String getCatalog()
throws SQLException
getCatalog in interface ConnectionSQLException
protected void finalize()
throws Throwable
This was done at the request of Rachel Greenham who hit a problem where multiple clients didn't close the connection, and once a fortnight enough clients were open to kill the postgres server.
finalize in class ObjectThrowablepublic String getDBVersionNumber()
public int getServerMajorVersion()
public int getServerMinorVersion()
public boolean haveMinimumServerVersion(String ver)
BaseConnection
haveMinimumServerVersion in interface BaseConnectionver - the server version to check
public boolean haveMinimumServerVersion(int ver)
BaseConnection
haveMinimumServerVersion in interface BaseConnectionver - the server version to check, of the form xxyyzz eg 90401
public boolean haveMinimumServerVersion(Version ver)
BaseConnection
haveMinimumServerVersion in interface BaseConnectionver - the server version to check
public boolean haveMinimumCompatibleVersion(int ver)
BaseConnection
haveMinimumCompatibleVersion in interface BaseConnectionver - the driver version to check, eg 90401 for 9.4.1
public boolean haveMinimumCompatibleVersion(String ver)
BaseConnection
haveMinimumCompatibleVersion in interface BaseConnectionver - the driver version to check
public boolean haveMinimumCompatibleVersion(Version ver)
BaseConnection
haveMinimumCompatibleVersion in interface BaseConnectionver - the driver version to check
public Encoding getEncoding()
getEncoding in interface BaseConnection
public byte[] encodeString(String str)
throws SQLException
BaseConnection
encodeString in interface BaseConnectionstr - the string to encode
SQLException - if something goes wrong.
public String escapeString(String str)
throws SQLException
BaseConnectionBaseConnection.getStandardConformingStrings().
escapeString in interface BaseConnectionstr - a string value
SQLException - if the string contains a \0 characterpublic boolean getStandardConformingStrings()
BaseConnection
getStandardConformingStrings in interface BaseConnectionProtocolConnection.getStandardConformingStrings()
public boolean isClosed()
throws SQLException
isClosed in interface ConnectionSQLException
public void cancelQuery()
throws SQLException
BaseConnection
cancelQuery in interface BaseConnectionSQLException - if something goes wrong.
public PGNotification[] getNotifications()
throws SQLException
PGConnection
getNotifications in interface PGConnectionSQLException - if something wrong happenspublic int getPrepareThreshold()
PGConnection
getPrepareThreshold in interface PGConnection
public void setDefaultFetchSize(int fetchSize)
throws SQLException
PGConnection
setDefaultFetchSize in interface PGConnectionfetchSize - new default fetch size
SQLException - if specified negative fetchSize parameterStatement.setFetchSize(int)public int getDefaultFetchSize()
PGConnection
getDefaultFetchSize in interface PGConnectionPGProperty.DEFAULT_ROW_FETCH_SIZE,
Statement.getFetchSize()public void setPrepareThreshold(int newThreshold)
PGConnectionPGStatement.setPrepareThreshold(int) for details.
setPrepareThreshold in interface PGConnectionnewThreshold - the new thresholdpublic boolean getForceBinary()
public void setForceBinary(boolean newValue)
public void setTypeMapImpl(Map<String,Class<?>> map)
throws SQLException
SQLExceptionpublic Logger getLogger()
getLogger in interface BaseConnectionpublic int getProtocolVersion()
public boolean getStringVarcharFlag()
getStringVarcharFlag in interface BaseConnection
public CopyManager getCopyAPI()
throws SQLException
PGConnection
getCopyAPI in interface PGConnectionSQLException - if something wrong happenspublic boolean binaryTransferSend(int oid)
BaseConnection
binaryTransferSend in interface BaseConnectionoid - The oid to check.
public int getBackendPID()
PGConnection
getBackendPID in interface PGConnectionpublic boolean isColumnSanitiserDisabled()
BaseConnection
isColumnSanitiserDisabled in interface BaseConnectionpublic void setDisableColumnSanitiser(boolean disableColumnSanitiser)
protected void abort()
public void addTimerTask(TimerTask timerTask,
long milliSeconds)
BaseConnection
addTimerTask in interface BaseConnectiontimerTask - timer task to schedulemilliSeconds - delay in millisecondspublic void purgeTimerTasks()
BaseConnection
purgeTimerTasks in interface BaseConnection
public String escapeIdentifier(String identifier)
throws SQLException
PGConnection
escapeIdentifier in interface PGConnectionidentifier - input identifier
SQLException - if something goes wrong
public String escapeLiteral(String literal)
throws SQLException
PGConnection
escapeLiteral in interface PGConnectionliteral - input literal
SQLException - if something goes wrong
public Statement createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
createStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
prepareStatement in interface ConnectionSQLException
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
prepareCall in interface ConnectionSQLException
public DatabaseMetaData getMetaData()
throws SQLException
getMetaData in interface ConnectionSQLException
public void setTypeMap(Map<String,Class<?>> map)
throws SQLException
setTypeMap in interface ConnectionSQLException
protected Array makeArray(int oid,
String fieldString)
throws SQLException
SQLException
protected Blob makeBlob(long oid)
throws SQLException
SQLException
protected Clob makeClob(long oid)
throws SQLException
SQLException
protected SQLXML makeSQLXML()
throws SQLException
SQLException
public Clob createClob()
throws SQLException
createClob in interface ConnectionSQLException
public Blob createBlob()
throws SQLException
createBlob in interface ConnectionSQLException
public NClob createNClob()
throws SQLException
createNClob in interface ConnectionSQLException
public SQLXML createSQLXML()
throws SQLException
createSQLXML in interface ConnectionSQLException
public Struct createStruct(String typeName,
Object[] attributes)
throws SQLException
createStruct in interface ConnectionSQLException
public Array createArrayOf(String typeName,
Object[] elements)
throws SQLException
createArrayOf in interface ConnectionSQLException
public boolean isValid(int timeout)
throws SQLException
isValid in interface ConnectionSQLException
public void setClientInfo(String name,
String value)
throws SQLClientInfoException
setClientInfo in interface ConnectionSQLClientInfoException
public void setClientInfo(Properties properties)
throws SQLClientInfoException
setClientInfo in interface ConnectionSQLClientInfoException
public String getClientInfo(String name)
throws SQLException
getClientInfo in interface ConnectionSQLException
public Properties getClientInfo()
throws SQLException
getClientInfo in interface ConnectionSQLException
public <T> T createQueryObject(Class<T> ifc)
throws SQLException
SQLException
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 String getSchema()
throws SQLException
SQLException
public void setSchema(String schema)
throws SQLException
SQLException
public void abort(Executor executor)
throws SQLException
SQLException
public void setNetworkTimeout(Executor executor,
int milliseconds)
throws SQLException
SQLException
public int getNetworkTimeout()
throws SQLException
SQLException
public void setHoldability(int holdability)
throws SQLException
setHoldability in interface ConnectionSQLException
public int getHoldability()
throws SQLException
getHoldability in interface ConnectionSQLException
public Savepoint setSavepoint()
throws SQLException
setSavepoint in interface ConnectionSQLException
public Savepoint setSavepoint(String name)
throws SQLException
setSavepoint in interface ConnectionSQLException
public void rollback(Savepoint savepoint)
throws SQLException
rollback in interface ConnectionSQLException
public void releaseSavepoint(Savepoint savepoint)
throws SQLException
releaseSavepoint in interface ConnectionSQLException
public Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws SQLException
createStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
prepareStatement in interface ConnectionSQLException
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
prepareCall in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int autoGeneratedKeys)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
int[] columnIndexes)
throws SQLException
prepareStatement in interface ConnectionSQLException
public PreparedStatement prepareStatement(String sql,
String[] columnNames)
throws SQLException
prepareStatement in interface ConnectionSQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||