to.etc.dbutil
Class PostgresDB

java.lang.Object
  extended by to.etc.dbutil.BaseDB
      extended by to.etc.dbutil.PostgresDB

public class PostgresDB
extends BaseDB


Constructor Summary
PostgresDB()
           
 
Method Summary
protected  java.lang.String getCheckString()
          Returns a SQL statement that is the cheapest way to check the validity of a connection.
protected  int getFullSequenceID(java.sql.Connection dbc, java.lang.String seqname)
          Uses a table sequence to generate a value.
protected  java.io.Reader getLobReader(java.sql.Connection dbc, java.sql.ResultSet rs, int col)
          Returns a Reader from the blob (clob) column specified.
protected  java.io.Reader getLobReader(java.sql.Connection dbc, java.sql.ResultSet rs, java.lang.String col)
          Returns a Reader from the blob (clob) column specified.
protected  java.io.InputStream getLobStream(java.sql.Connection dbc, java.sql.ResultSet rs, int col)
          Returns an InputStream from the blob (clob) column specified.
protected  java.io.InputStream getLobStream(java.sql.Connection dbc, java.sql.ResultSet rs, java.lang.String col)
          Returns an InputStream from the blob (clob) column specified.
protected  int getSequenceID(java.sql.Connection dbc, java.lang.String tablename)
          Returns a sequence number that can be used to create a new PK for a record in the given table.
protected  void setBlob(java.sql.Connection dbc, java.lang.String table, java.lang.String column, java.lang.String[] pkfields, java.lang.Object[] key, java.io.InputStream is)
           
protected  void setBlob(java.sql.Connection dbc, java.lang.String table, java.lang.String column, java.lang.String where, java.io.InputStream is)
          Writes a blob to the requested record using the normal setBinaryStream call.
protected  void setClob(java.sql.Connection dbc, java.lang.String table, java.lang.String column, java.lang.String where, java.io.Reader r)
          Writes a blob to the requested record using the normal setBinaryStream The Postgres impl converts the data to byte[] then stores, and the set interfaces do not work of course.
 
Methods inherited from class to.etc.dbutil.BaseDB
oracleOuterJoin, setBlob, streamCopy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostgresDB

public PostgresDB()
Method Detail

getCheckString

protected java.lang.String getCheckString()
Returns a SQL statement that is the cheapest way to check the validity of a connection.

Specified by:
getCheckString in class BaseDB
Returns:

getFullSequenceID

protected int getFullSequenceID(java.sql.Connection dbc,
                                java.lang.String seqname)
                         throws java.sql.SQLException
Uses a table sequence to generate a value.

Specified by:
getFullSequenceID in class BaseDB
Parameters:
dbc - the connection
Returns:
the id
Throws:
java.sql.SQLException - if the sequence could not be obtained

getSequenceID

protected int getSequenceID(java.sql.Connection dbc,
                            java.lang.String tablename)
                     throws java.sql.SQLException
Description copied from class: BaseDB
Returns a sequence number that can be used to create a new PK for a record in the given table. Sequences are emulated on databases that do not support 'm.

Specified by:
getSequenceID in class BaseDB
Returns:
Throws:
java.sql.SQLException

setBlob

protected void setBlob(java.sql.Connection dbc,
                       java.lang.String table,
                       java.lang.String column,
                       java.lang.String[] pkfields,
                       java.lang.Object[] key,
                       java.io.InputStream is)
                throws java.sql.SQLException
Specified by:
setBlob in class BaseDB
Throws:
java.sql.SQLException

setBlob

protected void setBlob(java.sql.Connection dbc,
                       java.lang.String table,
                       java.lang.String column,
                       java.lang.String where,
                       java.io.InputStream is)
                throws java.sql.SQLException
Writes a blob to the requested record using the normal setBinaryStream call. Used for jdbc-compliant databases.

Specified by:
setBlob in class BaseDB
Throws:
java.sql.SQLException

setClob

protected void setClob(java.sql.Connection dbc,
                       java.lang.String table,
                       java.lang.String column,
                       java.lang.String where,
                       java.io.Reader r)
                throws java.lang.Exception
Writes a blob to the requested record using the normal setBinaryStream The Postgres impl converts the data to byte[] then stores, and the set interfaces do not work of course. So we convert the shit to string then store it.

Specified by:
setClob in class BaseDB
Throws:
java.lang.Exception

getLobReader

protected java.io.Reader getLobReader(java.sql.Connection dbc,
                                      java.sql.ResultSet rs,
                                      int col)
                               throws java.lang.Exception
Returns a Reader from the blob (clob) column specified.

Specified by:
getLobReader in class BaseDB
Parameters:
rs -
col -
Returns:
Throws:
java.lang.Exception

getLobReader

protected java.io.Reader getLobReader(java.sql.Connection dbc,
                                      java.sql.ResultSet rs,
                                      java.lang.String col)
                               throws java.lang.Exception
Returns a Reader from the blob (clob) column specified.

Specified by:
getLobReader in class BaseDB
Parameters:
rs -
col -
Returns:
Throws:
java.lang.Exception

getLobStream

protected java.io.InputStream getLobStream(java.sql.Connection dbc,
                                           java.sql.ResultSet rs,
                                           int col)
                                    throws java.lang.Exception
Returns an InputStream from the blob (clob) column specified.

Specified by:
getLobStream in class BaseDB
Parameters:
rs -
col -
Returns:
Throws:
java.lang.Exception

getLobStream

protected java.io.InputStream getLobStream(java.sql.Connection dbc,
                                           java.sql.ResultSet rs,
                                           java.lang.String col)
                                    throws java.lang.Exception
Returns an InputStream from the blob (clob) column specified.

Specified by:
getLobStream in class BaseDB
Parameters:
rs -
col -
Returns:
Throws:
java.lang.Exception