public abstract class AbstractJdbc2Connection extends java.lang.Object implements BaseConnection
| Modifier and Type | Field and Description |
|---|---|
boolean |
autoCommit |
boolean |
bindStringAsVarchar |
java.sql.SQLWarning |
firstWarning |
protected java.sql.DatabaseMetaData |
metadata |
protected int |
prepareThreshold |
boolean |
readOnly |
protected java.util.Map |
typemap |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractJdbc2Connection(java.lang.String host,
int port,
java.lang.String user,
java.lang.String database,
java.util.Properties info,
java.lang.String url) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDataType(java.lang.String type,
java.lang.Class klass)
This allows client code to add a handler for one of org.postgresql's
more unique data types.
|
void |
addDataType(java.lang.String type,
java.lang.String name)
This allows client code to add a handler for one of org.postgresql's
more unique data types.
|
void |
addWarning(java.sql.SQLWarning warn) |
void |
cancelQuery()
Cancel the current query executing on this connection.
|
protected void |
checkClosed() |
void |
clearWarnings() |
void |
close()
In some cases, it is desirable to immediately release a Connection's
database and JDBC resources instead of waiting for them to be
automatically released.
|
void |
commit() |
java.sql.Statement |
createStatement() |
abstract java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency) |
protected TypeInfo |
createTypeInfo(BaseConnection conn,
int unknownLength) |
protected void |
enableDriverManagerLogging() |
byte[] |
encodeString(java.lang.String str)
Encode a string using the database's client_encoding
(usually UTF8, but can vary on older server versions).
|
java.lang.String |
escapeString(java.lang.String str)
Escapes a string for use as string-literal within an SQL command.
|
java.sql.ResultSet |
execSQLQuery(java.lang.String s)
Execute a SQL query that returns a single resultset.
|
java.sql.ResultSet |
execSQLQuery(java.lang.String s,
int resultSetType,
int resultSetConcurrency)
Simple query execution.
|
void |
execSQLUpdate(java.lang.String s)
Execute a SQL query that does not return results.
|
protected void |
finalize() |
boolean |
getAutoCommit() |
java.lang.String |
getCatalog() |
CopyManager |
getCopyAPI()
This returns the COPY API for the current connection.
|
java.lang.String |
getCursorName() |
java.lang.String |
getDBVersionNumber() |
Encoding |
getEncoding() |
Fastpath |
getFastpathAPI()
This returns the Fastpath API for the current connection.
|
protected java.lang.String |
getIsolationLevelName(int level) |
LargeObjectManager |
getLargeObjectAPI()
This returns the LargeObject API for the current connection.
|
Logger |
getLogger() |
abstract java.sql.DatabaseMetaData |
getMetaData() |
PGNotification[] |
getNotifications()
This method returns any notifications that have been received
since the last call to this method.
|
java.lang.Object |
getObject(java.lang.String type,
java.lang.String value)
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.
|
int |
getServerMajorVersion() |
int |
getServerMinorVersion() |
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() |
java.util.Map |
getTypeMap() |
java.lang.String |
getURL() |
java.lang.String |
getUserName() |
java.sql.SQLWarning |
getWarnings() |
boolean |
haveMinimumCompatibleVersion(java.lang.String ver)
Check if we should use driver behaviour introduced in a particular
driver version.
|
boolean |
haveMinimumServerVersion(java.lang.String ver)
Is the server we are connected to running at least this version?
|
boolean |
isClosed() |
boolean |
isReadOnly() |
java.lang.String |
nativeSQL(java.lang.String sql) |
java.sql.CallableStatement |
prepareCall(java.lang.String sql) |
abstract java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency) |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql) |
abstract java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency) |
void |
rollback() |
void |
setAutoCommit(boolean autoCommit) |
void |
setCatalog(java.lang.String catalog) |
void |
setCursorName(java.lang.String cursor) |
void |
setPrepareThreshold(int newThreshold)
Set the default statement reuse threshold before enabling server-side
prepare.
|
void |
setReadOnly(boolean readOnly) |
void |
setTransactionIsolation(int level) |
void |
setTypeMapImpl(java.util.Map map) |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitabort, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStruct, getClientInfo, getClientInfo, getHoldability, getNetworkTimeout, getSchema, isValid, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setSavepoint, setSavepoint, setSchema, setTypeMapprotected int prepareThreshold
public boolean autoCommit
public boolean readOnly
public final boolean bindStringAsVarchar
public java.sql.SQLWarning firstWarning
protected java.util.Map typemap
protected java.sql.DatabaseMetaData metadata
protected AbstractJdbc2Connection(java.lang.String host,
int port,
java.lang.String user,
java.lang.String database,
java.util.Properties info,
java.lang.String url)
throws java.sql.SQLException
java.sql.SQLExceptionpublic abstract java.sql.DatabaseMetaData getMetaData()
throws java.sql.SQLException
getMetaData in interface java.sql.Connectionjava.sql.SQLExceptionpublic TimestampUtils getTimestampUtils()
getTimestampUtils in interface BaseConnectionpublic java.sql.Statement createStatement()
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic abstract java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic abstract java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.CallableStatement prepareCall(java.lang.String sql)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.sql.SQLExceptionpublic abstract java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.util.Map getTypeMap()
throws java.sql.SQLException
getTypeMap in interface java.sql.Connectionjava.sql.SQLExceptionpublic QueryExecutor getQueryExecutor()
BaseConnectiongetQueryExecutor in interface BaseConnectionpublic void addWarning(java.sql.SQLWarning warn)
public java.sql.ResultSet execSQLQuery(java.lang.String s)
throws java.sql.SQLException
BaseConnectionexecSQLQuery in interface BaseConnections - the query to executejava.sql.SQLException - if something goes wrong.public java.sql.ResultSet execSQLQuery(java.lang.String s,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
execSQLQuery in interface BaseConnectionjava.sql.SQLExceptionpublic void execSQLUpdate(java.lang.String s)
throws java.sql.SQLException
BaseConnectionexecSQLUpdate in interface BaseConnections - the query to executejava.sql.SQLException - if something goes wrong.public void setCursorName(java.lang.String cursor)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String getCursorName()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String getURL()
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.lang.String getUserName()
throws java.sql.SQLException
java.sql.SQLExceptionpublic Fastpath getFastpathAPI() throws java.sql.SQLException
PGConnectiongetFastpathAPI in interface PGConnectionjava.sql.SQLExceptionpublic LargeObjectManager getLargeObjectAPI() throws java.sql.SQLException
PGConnectiongetLargeObjectAPI in interface PGConnectionjava.sql.SQLExceptionpublic java.lang.Object getObject(java.lang.String type,
java.lang.String value)
throws java.sql.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 valuejava.sql.SQLException - if something goes wrongprotected TypeInfo createTypeInfo(BaseConnection conn, int unknownLength)
public TypeInfo getTypeInfo()
getTypeInfo in interface BaseConnectionpublic void addDataType(java.lang.String type,
java.lang.String name)
PGConnectionaddDataType(type, Class.forName(name)).addDataType in interface PGConnectionpublic void addDataType(java.lang.String type,
java.lang.Class klass)
throws java.sql.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).java.sql.SQLException - if klass does not implement
PGobject).PGobjectpublic void close()
close in interface java.lang.AutoCloseableclose in interface java.sql.Connectionjava.sql.SQLException - if a database access error occurspublic java.lang.String nativeSQL(java.lang.String sql)
throws java.sql.SQLException
nativeSQL in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
getWarnings in interface java.sql.Connectionjava.sql.SQLExceptionpublic void clearWarnings()
throws java.sql.SQLException
clearWarnings in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setReadOnly(boolean readOnly)
throws java.sql.SQLException
setReadOnly in interface java.sql.Connectionjava.sql.SQLExceptionpublic boolean isReadOnly()
throws java.sql.SQLException
isReadOnly in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setAutoCommit(boolean autoCommit)
throws java.sql.SQLException
setAutoCommit in interface java.sql.Connectionjava.sql.SQLExceptionpublic boolean getAutoCommit()
throws java.sql.SQLException
getAutoCommit in interface java.sql.Connectionjava.sql.SQLExceptionpublic void commit()
throws java.sql.SQLException
commit in interface java.sql.Connectionjava.sql.SQLExceptionprotected void checkClosed()
throws java.sql.SQLException
java.sql.SQLExceptionpublic void rollback()
throws java.sql.SQLException
rollback in interface java.sql.Connectionjava.sql.SQLExceptionpublic int getTransactionState()
BaseConnectiongetTransactionState in interface BaseConnectionpublic int getTransactionIsolation()
throws java.sql.SQLException
getTransactionIsolation in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setTransactionIsolation(int level)
throws java.sql.SQLException
setTransactionIsolation in interface java.sql.Connectionjava.sql.SQLExceptionprotected java.lang.String getIsolationLevelName(int level)
public void setCatalog(java.lang.String catalog)
throws java.sql.SQLException
setCatalog in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.lang.String getCatalog()
throws java.sql.SQLException
getCatalog in interface java.sql.Connectionjava.sql.SQLExceptionprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic java.lang.String getDBVersionNumber()
public int getServerMajorVersion()
public int getServerMinorVersion()
public boolean haveMinimumServerVersion(java.lang.String ver)
haveMinimumServerVersion in interface BaseConnectionver - the server version to checkpublic boolean haveMinimumCompatibleVersion(java.lang.String ver)
BaseConnectionhaveMinimumCompatibleVersion in interface BaseConnectionver - the driver version to checkpublic Encoding getEncoding()
getEncoding in interface BaseConnectionpublic byte[] encodeString(java.lang.String str)
throws java.sql.SQLException
BaseConnectionencodeString in interface BaseConnectionstr - the string to encodejava.sql.SQLException - if something goes wrong.public java.lang.String escapeString(java.lang.String str)
throws java.sql.SQLException
BaseConnectionBaseConnection.getStandardConformingStrings().escapeString in interface BaseConnectionstr - a string valuejava.sql.SQLException - if the string contains a \0 characterpublic boolean getStandardConformingStrings()
BaseConnectiongetStandardConformingStrings in interface BaseConnectionProtocolConnection.getStandardConformingStrings()public boolean isClosed()
throws java.sql.SQLException
isClosed in interface java.sql.Connectionjava.sql.SQLExceptionpublic void cancelQuery()
throws java.sql.SQLException
BaseConnectioncancelQuery in interface BaseConnectionjava.sql.SQLException - if something goes wrong.public PGNotification[] getNotifications() throws java.sql.SQLException
PGConnectiongetNotifications in interface PGConnectionjava.sql.SQLExceptionpublic int getPrepareThreshold()
PGConnectiongetPrepareThreshold in interface PGConnectionpublic void setPrepareThreshold(int newThreshold)
PGConnectionPGStatement.setPrepareThreshold(int) for
details.setPrepareThreshold in interface PGConnectionnewThreshold - the new thresholdpublic void setTypeMapImpl(java.util.Map map)
throws java.sql.SQLException
java.sql.SQLExceptionpublic Logger getLogger()
getLogger in interface BaseConnectionprotected void enableDriverManagerLogging()
public int getProtocolVersion()
public boolean getStringVarcharFlag()
getStringVarcharFlag in interface BaseConnectionpublic CopyManager getCopyAPI() throws java.sql.SQLException
PGConnectiongetCopyAPI in interface PGConnectionjava.sql.SQLException