org.postgresql.pljava.jdbc
Class SPIConnection

java.lang.Object
  extended by org.postgresql.pljava.jdbc.SPIConnection
All Implemented Interfaces:
java.sql.Connection, java.sql.Wrapper

public class SPIConnection
extends java.lang.Object
implements java.sql.Connection

Provides access to the current connection (session) the Java stored procedure is running in. It is returned from the driver manager with DriverManager.getConnection("jdbc:default:connection"); and cannot be managed in any way since it's already running inside a transaction. This means the following methods cannot be used.


Field Summary
static int[] JDBC_TYPE_NUMBERS
           
static java.lang.String[] JDBC3_TYPE_NAMES
           
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
SPIConnection()
           
 
Method Summary
 void clearWarnings()
          Warnings are not yet supported.
 void close()
          This is a no-op.
 void commit()
          It's not legal to do a commit within a call from SQL.
 java.sql.Array createArrayOf(java.lang.String typeName, java.lang.Object[] elements)
           
 java.sql.Blob createBlob()
           
 java.sql.Clob createClob()
           
 java.sql.NClob createNClob()
           
 java.sql.SQLXML createSQLXML()
           
 java.sql.Statement createStatement()
          Creates a new instance of SPIStatement.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          Creates a new instance of SPIStatement.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Creates a new instance of SPIStatement.
 java.sql.Struct createStruct(java.lang.String typeName, java.lang.Object[] attributes)
           
 boolean getAutoCommit()
          It is assumed that an SPI call is under transaction control.
 java.lang.String getCatalog()
          Returns the database in which we are running.
 java.util.Properties getClientInfo()
           
 java.lang.String getClientInfo(java.lang.String name)
           
static java.sql.Connection getDefault()
          Returns a default connection instance.
 int getHoldability()
          Returns ResultSet.CLOSE_CURSORS_AT_COMMIT.
 java.sql.DatabaseMetaData getMetaData()
          Retrieves an instance of SPIDatabaseMetaData representing this Connection object.
 java.lang.String getPGType(Oid oid)
           
 int getSQLType(Oid oid)
           
 int getSQLType(java.lang.String pgTypeName)
           
 int getTransactionIsolation()
          Returns Connection.TRANSACTION_READ_COMMITTED.
 java.util.Map getTypeMap()
          Returns null.
 int[] getVersionNumber()
           
 java.sql.SQLWarning getWarnings()
          Warnings are not yet supported.
 boolean isClosed()
          Will always return false.
 boolean isReadOnly()
          Returns false.
 boolean isValid(int timeout)
           
 boolean isWrapperFor(java.lang.Class<?> iface)
           
 java.lang.String nativeSQL(java.lang.String sql)
          Parse the JDBC SQL into PostgreSQL.
 java.lang.String nativeSQL(java.lang.String sql, int[] paramCountRet)
           
 java.sql.CallableStatement prepareCall(java.lang.String sql)
          Procedure calls are not yet implemented.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          Procedure calls are not yet implemented.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Procedure calls are not yet implemented.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Creates a new instance of SPIPreparedStatement.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys)
          Return of auto generated keys is not yet supported.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes)
          Return of auto generated keys is not yet supported.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          Creates a new instance of SPIPreparedStatement.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Creates a new instance of SPIPreparedStatement.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames)
          Return of auto generated keys is not yet supported.
 void releaseSavepoint(java.sql.Savepoint savepoint)
           
 void rollback()
          It's not legal to do a rollback within a call from SQL.
 void rollback(java.sql.Savepoint savepoint)
           
 void setAutoCommit(boolean autoCommit)
          It is assumed that an SPI call is under transaction control.
 void setCatalog(java.lang.String catalog)
          The catalog name cannot be set.
 void setClientInfo(java.util.Properties properties)
           
 void setClientInfo(java.lang.String name, java.lang.String value)
           
 void setHoldability(int holdability)
          Change of holdability is not supported.
 void setReadOnly(boolean readOnly)
          It is assumed that an inserts and updates can be performed using and SPIConnection.
 java.sql.Savepoint setSavepoint()
           
 java.sql.Savepoint setSavepoint(java.lang.String name)
           
 void setTransactionIsolation(int level)
          Change of transaction isolation level is not supported.
 void setTypeMap(java.util.Map map)
          Type map is not yet implemented.
<T> T
unwrap(java.lang.Class<T> iface)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JDBC3_TYPE_NAMES

public static final java.lang.String[] JDBC3_TYPE_NAMES

JDBC_TYPE_NUMBERS

public static final int[] JDBC_TYPE_NUMBERS
Constructor Detail

SPIConnection

public SPIConnection()
Method Detail

getDefault

public static java.sql.Connection getDefault()
                                      throws java.sql.SQLException
Returns a default connection instance. It is the callers responsability to close this instance.

Throws:
java.sql.SQLException

getHoldability

public int getHoldability()
Returns ResultSet.CLOSE_CURSORS_AT_COMMIT. Cursors are actually closed when a function returns to SQL.

Specified by:
getHoldability in interface java.sql.Connection

getTransactionIsolation

public int getTransactionIsolation()
Returns Connection.TRANSACTION_READ_COMMITTED.

Specified by:
getTransactionIsolation in interface java.sql.Connection

clearWarnings

public void clearWarnings()
                   throws java.sql.SQLException
Warnings are not yet supported.

Specified by:
clearWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

close

public void close()
This is a no-op. The default connection never closes.

Specified by:
close in interface java.sql.Connection

commit

public void commit()
            throws java.sql.SQLException
It's not legal to do a commit within a call from SQL.

Specified by:
commit in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

rollback

public void rollback()
              throws java.sql.SQLException
It's not legal to do a rollback within a call from SQL.

Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

getAutoCommit

public boolean getAutoCommit()
It is assumed that an SPI call is under transaction control. This method will always return false.

Specified by:
getAutoCommit in interface java.sql.Connection

isClosed

public boolean isClosed()
Will always return false.

Specified by:
isClosed in interface java.sql.Connection

isReadOnly

public boolean isReadOnly()
Returns false. The SPIConnection is not real-only.

Specified by:
isReadOnly in interface java.sql.Connection

setHoldability

public void setHoldability(int holdability)
                    throws java.sql.SQLException
Change of holdability is not supported.

Specified by:
setHoldability in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws java.sql.SQLException
Change of transaction isolation level is not supported.

Specified by:
setTransactionIsolation in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws java.sql.SQLException
It is assumed that an SPI call is under transaction control. Changing that is not supported.

Specified by:
setAutoCommit in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws java.sql.SQLException
It is assumed that an inserts and updates can be performed using and SPIConnection. Changing that is not supported.

Specified by:
setReadOnly in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

getCatalog

public java.lang.String getCatalog()
                            throws java.sql.SQLException
Returns the database in which we are running.

Specified by:
getCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
The catalog name cannot be set.

Specified by:
setCatalog in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

getMetaData

public java.sql.DatabaseMetaData getMetaData()
Retrieves an instance of SPIDatabaseMetaData representing this Connection object. The metadata includes information about the SQL grammar supported by PostgreSQL, the capabilities of PL/Java, as well as the tables and stored procedures for this connection and so on.

Specified by:
getMetaData in interface java.sql.Connection
Returns:
an SPIDatabaseMetaData object for this Connection object

getWarnings

public java.sql.SQLWarning getWarnings()
                                throws java.sql.SQLException
Warnings are not yet supported.

Specified by:
getWarnings in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

releaseSavepoint

public void releaseSavepoint(java.sql.Savepoint savepoint)
                      throws java.sql.SQLException
Specified by:
releaseSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException

rollback

public void rollback(java.sql.Savepoint savepoint)
              throws java.sql.SQLException
Specified by:
rollback in interface java.sql.Connection
Throws:
java.sql.SQLException

createStatement

public java.sql.Statement createStatement()
                                   throws java.sql.SQLException
Creates a new instance of SPIStatement.

Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws java.sql.SQLException
Creates a new instance of SPIStatement.

Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - if the resultSetType differs from ResultSet.TYPE_FORWARD_ONLY or if the resultSetConcurrencty differs from ResultSet.CONCUR_READ_ONLY.

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws java.sql.SQLException
Creates a new instance of SPIStatement.

Specified by:
createStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - if the resultSetType differs from ResultSet.TYPE_FORWARD_ONLY, if the resultSetConcurrencty differs from ResultSet.CONCUR_READ_ONLY, or if the resultSetHoldability differs from ResultSet.CLOSE_CURSORS_AT_COMMIT.

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
Returns null. Type map is not yet imlemented.

Specified by:
getTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException

setTypeMap

public void setTypeMap(java.util.Map map)
                throws java.sql.SQLException
Type map is not yet implemented.

Specified by:
setTypeMap in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql)
                           throws java.sql.SQLException
Parse the JDBC SQL into PostgreSQL.

Specified by:
nativeSQL in interface java.sql.Connection
Throws:
java.sql.SQLException

nativeSQL

public java.lang.String nativeSQL(java.lang.String sql,
                                  int[] paramCountRet)

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Procedure calls are not yet implemented.

Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency)
                                       throws java.sql.SQLException
Procedure calls are not yet implemented.

Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency,
                                              int resultSetHoldability)
                                       throws java.sql.SQLException
Procedure calls are not yet implemented.

Specified by:
prepareCall in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
Creates a new instance of SPIPreparedStatement.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int autoGeneratedKeys)
                                            throws java.sql.SQLException
Return of auto generated keys is not yet supported.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException
Creates a new instance of SPIPreparedStatement.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - if the resultSetType differs from ResultSet.TYPE_FORWARD_ONLY or if the resultSetConcurrencty differs from ResultSet.CONCUR_READ_ONLY.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency,
                                                   int resultSetHoldability)
                                            throws java.sql.SQLException
Creates a new instance of SPIPreparedStatement.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - if the resultSetType differs from ResultSet.TYPE_FORWARD_ONLY, if the resultSetConcurrencty differs from ResultSet.CONCUR_READ_ONLY, or if the resultSetHoldability differs from ResultSet.CLOSE_CURSORS_AT_COMMIT.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int[] columnIndexes)
                                            throws java.sql.SQLException
Return of auto generated keys is not yet supported.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   java.lang.String[] columnNames)
                                            throws java.sql.SQLException
Return of auto generated keys is not yet supported.

Specified by:
prepareStatement in interface java.sql.Connection
Throws:
java.sql.SQLException - indicating that this feature is not supported.

setSavepoint

public java.sql.Savepoint setSavepoint()
                                throws java.sql.SQLException
Specified by:
setSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException

setSavepoint

public java.sql.Savepoint setSavepoint(java.lang.String name)
                                throws java.sql.SQLException
Specified by:
setSavepoint in interface java.sql.Connection
Throws:
java.sql.SQLException

getVersionNumber

public int[] getVersionNumber()
                       throws java.sql.SQLException
Throws:
java.sql.SQLException

getSQLType

public int getSQLType(java.lang.String pgTypeName)

getSQLType

public int getSQLType(Oid oid)
               throws java.sql.SQLException
Throws:
java.sql.SQLException

getPGType

public java.lang.String getPGType(Oid oid)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

createStruct

public java.sql.Struct createStruct(java.lang.String typeName,
                                    java.lang.Object[] attributes)
                             throws java.sql.SQLException
Specified by:
createStruct in interface java.sql.Connection
Throws:
java.sql.SQLException

createArrayOf

public java.sql.Array createArrayOf(java.lang.String typeName,
                                    java.lang.Object[] elements)
                             throws java.sql.SQLException
Specified by:
createArrayOf in interface java.sql.Connection
Throws:
java.sql.SQLException

isValid

public boolean isValid(int timeout)
                throws java.sql.SQLException
Specified by:
isValid in interface java.sql.Connection
Throws:
java.sql.SQLException

createSQLXML

public java.sql.SQLXML createSQLXML()
                             throws java.sql.SQLException
Specified by:
createSQLXML in interface java.sql.Connection
Throws:
java.sql.SQLException

createNClob

public java.sql.NClob createNClob()
                           throws java.sql.SQLException
Specified by:
createNClob in interface java.sql.Connection
Throws:
java.sql.SQLException

createBlob

public java.sql.Blob createBlob()
                         throws java.sql.SQLException
Specified by:
createBlob in interface java.sql.Connection
Throws:
java.sql.SQLException

createClob

public java.sql.Clob createClob()
                         throws java.sql.SQLException
Specified by:
createClob in interface java.sql.Connection
Throws:
java.sql.SQLException

isWrapperFor

public boolean isWrapperFor(java.lang.Class<?> iface)
                     throws java.sql.SQLException
Specified by:
isWrapperFor in interface java.sql.Wrapper
Throws:
java.sql.SQLException

unwrap

public <T> T unwrap(java.lang.Class<T> iface)
         throws java.sql.SQLException
Specified by:
unwrap in interface java.sql.Wrapper
Throws:
java.sql.SQLException

setClientInfo

public void setClientInfo(java.lang.String name,
                          java.lang.String value)
                   throws java.sql.SQLClientInfoException
Specified by:
setClientInfo in interface java.sql.Connection
Throws:
java.sql.SQLClientInfoException

setClientInfo

public void setClientInfo(java.util.Properties properties)
                   throws java.sql.SQLClientInfoException
Specified by:
setClientInfo in interface java.sql.Connection
Throws:
java.sql.SQLClientInfoException

getClientInfo

public java.lang.String getClientInfo(java.lang.String name)
                               throws java.sql.SQLException
Specified by:
getClientInfo in interface java.sql.Connection
Throws:
java.sql.SQLException

getClientInfo

public java.util.Properties getClientInfo()
                                   throws java.sql.SQLException
Specified by:
getClientInfo in interface java.sql.Connection
Throws:
java.sql.SQLException


Copyright (c) 2003, 2004, 2005 TADA AB - Taby Sweden. \ Distributed under the terms shown in COPYRIGHT