org.postgresql.core
Interface BaseConnection

All Superinterfaces:
java.sql.Connection, PGConnection
All Known Implementing Classes:
AbstractJdbc2Connection, AbstractJdbc3Connection, Jdbc3gConnection

public interface BaseConnection
extends PGConnection, java.sql.Connection

Driver-internal connection interface. Application code should not use this interface.


Field Summary
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Method Summary
 void cancelQuery()
          Cancel the current query executing on this connection.
 byte[] encodeString(java.lang.String str)
          Encode a string using the database's client_encoding (usually UNICODE, 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)
           
 void execSQLUpdate(java.lang.String s)
          Execute a SQL query that does not return results.
 java.lang.String getJavaClass(int oid)
           
 Logger getLogger()
           
 java.lang.Object getObject(java.lang.String type, java.lang.String value)
          Construct and return an appropriate object for the given type and value.
 java.lang.String getPGType(int oid)
          Look up the postgresql type name for a given oid.
 int getPGType(java.lang.String pgTypeName)
          Look up the oid for a given postgresql type name.
 QueryExecutor getQueryExecutor()
          Get the QueryExecutor implementation for this connection.
 int getSQLType(int oid)
          Look up the SQL typecode for a given type oid.
 int getSQLType(java.lang.String pgTypeName)
          Look up the SQL typecode for a given postgresql type name.
 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()
           
 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)
          Check if we have at least a particular server version.
 
Methods inherited from interface org.postgresql.PGConnection
addDataType, addDataType, getEncoding, getFastpathAPI, getLargeObjectAPI, getNotifications, getPrepareThreshold, setPrepareThreshold
 
Methods inherited from interface java.sql.Connection
clearWarnings, close, commit, createStatement, createStatement, createStatement, getAutoCommit, getCatalog, getHoldability, getMetaData, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTransactionIsolation, setTypeMap
 

Method Detail

cancelQuery

void cancelQuery()
                 throws java.sql.SQLException
Cancel the current query executing on this connection.

Throws:
java.sql.SQLException - if something goes wrong.

execSQLQuery

java.sql.ResultSet execSQLQuery(java.lang.String s)
                                throws java.sql.SQLException
Execute a SQL query that returns a single resultset. Never causes a new transaction to be started regardless of the autocommit setting.

Parameters:
s - the query to execute
Returns:
the (non-null) returned resultset
Throws:
java.sql.SQLException - if something goes wrong.

execSQLQuery

java.sql.ResultSet execSQLQuery(java.lang.String s,
                                int resultSetType,
                                int resultSetConcurrency)
                                throws java.sql.SQLException
Throws:
java.sql.SQLException

execSQLUpdate

void execSQLUpdate(java.lang.String s)
                   throws java.sql.SQLException
Execute a SQL query that does not return results. Never causes a new transaction to be started regardless of the autocommit setting.

Parameters:
s - the query to execute
Throws:
java.sql.SQLException - if something goes wrong.

getQueryExecutor

QueryExecutor getQueryExecutor()
Get the QueryExecutor implementation for this connection.

Returns:
the (non-null) executor

getObject

java.lang.Object getObject(java.lang.String type,
                           java.lang.String value)
                           throws java.sql.SQLException
Construct and return an appropriate object for the given type and value. This only considers the types registered via PGConnection.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.

Specified by:
getObject in interface PGConnection
Parameters:
type - the backend typename
value - the type-specific string representation of the value
Returns:
an appropriate object; never null.
Throws:
java.sql.SQLException - if something goes wrong

getJavaClass

java.lang.String getJavaClass(int oid)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

getPGType

java.lang.String getPGType(int oid)
                           throws java.sql.SQLException
Look up the postgresql type name for a given oid. This is the inverse of getPGType(String).

Specified by:
getPGType in interface PGConnection
Parameters:
oid - the type's OID
Returns:
the server type name for that OID, or null if unknown
Throws:
java.sql.SQLException - if something goes wrong

getPGType

int getPGType(java.lang.String pgTypeName)
              throws java.sql.SQLException
Look up the oid for a given postgresql type name. This is the inverse of getPGType(int).

Specified by:
getPGType in interface PGConnection
Parameters:
pgTypeName - the server type name to look up
Returns:
oid the type's OID, or 0 if unknown
Throws:
java.sql.SQLException - if something goes wrong

getSQLType

int getSQLType(int oid)
               throws java.sql.SQLException
Look up the SQL typecode for a given type oid.

Specified by:
getSQLType in interface PGConnection
Parameters:
oid - the type's OID
Returns:
the SQL typecode (a constant from Types) for the type
Throws:
java.sql.SQLException - if something goes wrong

getSQLType

int getSQLType(java.lang.String pgTypeName)
               throws java.sql.SQLException
Look up the SQL typecode for a given postgresql type name.

Specified by:
getSQLType in interface PGConnection
Parameters:
pgTypeName - the server type name to look up
Returns:
the SQL typecode (a constant from Types) for the type
Throws:
java.sql.SQLException - if something goes wrong

haveMinimumCompatibleVersion

boolean haveMinimumCompatibleVersion(java.lang.String ver)
Check if we should use driver behaviour introduced in a particular driver version. This defaults to behaving as the actual driver's version but can be overridden by the "compatible" URL parameter.

Parameters:
ver - the driver version to check
Returns:
true if the driver's behavioural version is at least "ver".
Throws:
java.sql.SQLException - if something goes wrong

haveMinimumServerVersion

boolean haveMinimumServerVersion(java.lang.String ver)
Check if we have at least a particular server version.

Parameters:
ver - the server version to check
Returns:
true if the server version is at least "ver".
Throws:
java.sql.SQLException - if something goes wrong

encodeString

byte[] encodeString(java.lang.String str)
                    throws java.sql.SQLException
Encode a string using the database's client_encoding (usually UNICODE, but can vary on older server versions). This is used when constructing synthetic resultsets (for example, in metadata methods).

Parameters:
str - the string to encode
Returns:
an encoded representation of the string
Throws:
java.sql.SQLException - if something goes wrong.

escapeString

java.lang.String escapeString(java.lang.String str)
                              throws java.sql.SQLException
Escapes a string for use as string-literal within an SQL command. The method chooses the applicable escaping rules based on the value of getStandardConformingStrings().

Parameters:
str - a string value
Returns:
the escaped representation of the string
Throws:
java.sql.SQLException - if the string contains a \0 character

getStandardConformingStrings

boolean getStandardConformingStrings()
Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules. Versions up to 8.1 always treated backslashes as escape characters in string-literals. Since 8.2, this depends on the value of the standard_conforming_strings server variable.

Returns:
true if the server treats string literals according to the SQL standard
See Also:
ProtocolConnection.getStandardConformingStrings()

getTimestampUtils

TimestampUtils getTimestampUtils()

getLogger

Logger getLogger()

getStringVarcharFlag

boolean getStringVarcharFlag()