jxDBCon 0.9z

org.sourceforge.jxdbcon.postgresql
Class IntConnection

java.lang.Object
  |
  +--org.sourceforge.jxdbcon.AbstractConnection
        |
        +--org.sourceforge.jxdbcon.postgresql.PGConnection
              |
              +--org.sourceforge.jxdbcon.postgresql.IntConnection
All Implemented Interfaces:
Cloneable, Connection, InfoKeys, PGInfoKeys, Runnable

public class IntConnection
extends PGConnection
implements Runnable

This class implements PGConnection via a special Socket connection. It will be used once a proper java enabled procedural language is implemented. Currently it is designed to work against the preliminary sample implementation pl/jx that is part of jxDBCon.

Version:
$Revision: 1.5 $
Author:
Keve Müller

Nested Class Summary
static class IntConnection.Server
           
 
Field Summary
private static ThreadLocal conninstance
           
(package private)  Map functionCache
           
private  IntProtocol proto
           
(package private)  File scratchDir
           
(package private)  ClassLoader scratchLoader
           
 
Fields inherited from class org.sourceforge.jxdbcon.postgresql.PGConnection
autoCommit, clientEncoding, dbEncoding, isBigEndian, oidTypeMap
 
Fields inherited from class org.sourceforge.jxdbcon.AbstractConnection
info, typeMap, warning
 
Fields inherited from interface org.sourceforge.jxdbcon.postgresql.PGInfoKeys
FORCECLIENTENC, OPTIONS, PROTOVERSION, SETTIMEZONE, STRICTSCHEMA, TTY, USEASYNC, USECLIENTENC, USEDBENC, USESSL
 
Fields inherited from interface org.sourceforge.jxdbcon.InfoKeys
CATALOG, DESCRIPTION, DRIVER, HOST, PASSWORD, PORT, SUBDRIVER, USER
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
IntConnection(IntProtocol proto)
          Construct the connection instance.
 
Method Summary
protected  PGProtocol connect(Properties info)
          Open a connection.
(package private)  Object doFunctionCall(long funcOid, String src, Object[] paramObject, AbstractType rt, AbstractType[] at)
           
 PGFuncResult exec(long funcOid, byte[][] param)
           
 PGExecResult exec(String sql)
           
 PGFunc[] findFunc(long funcOid, int argLen)
          Find a PostgreSQL function by oid and parameter list length.
 int getTransactionIsolation()
          Get the transaction isolation level.
(package private)  AbstractType getTypeFromOid(long oid)
          Get the AbstractType for an oid.
static IntConnection internalConnection()
           
(package private)  void manageComment(IntProtocol.CommentQuery q)
           
(package private)  void manageConnect(IntProtocol.ConnectQuery q)
           
(package private)  void manageFunctionCall(IntProtocol.FunctionCallQuery q)
          High level communcation function to execute a locally known function and return its result.
(package private)  void prepareClassLoader()
           
(package private)  IntProtocol.Type queryType(long oid)
          High level communication function for querying pg_type given the oid.
 void run()
           
 void setCopyInStream(InputStream in)
           
 void setCopyOutStream(OutputStream out)
           
 
Methods inherited from class org.sourceforge.jxdbcon.postgresql.PGConnection
close, commit, createStatement, exec, executeBatch, executeSQL, fillPropertyInfo, findFunc, findFunc, getAutoCommit, getConversionContext, getEscapeContext, getGeneratedKeys, getMetaData, getProtocol, getResultSet, getResultSet, getType, getType, getTypeOid, open, prepareCall, prepareStatement, res2Types, rollback, setAutoCommit, setCatalog, setTransactionIsolation, takeOver, toString
 
Methods inherited from class org.sourceforge.jxdbcon.AbstractConnection
clearWarnings, clone, createStatement, createStatement, duplicate, finalize, getCatalog, getHoldability, getInfo, getTypeMap, getWarnings, isClosed, isReadOnly, nativeSQL, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setHoldability, setReadOnly, setSavepoint, setSavepoint, setTypeMap
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

conninstance

private static ThreadLocal conninstance

functionCache

Map functionCache

proto

private IntProtocol proto

scratchDir

File scratchDir

scratchLoader

ClassLoader scratchLoader
Constructor Detail

IntConnection

public IntConnection(IntProtocol proto)
              throws SQLException
Construct the connection instance.

Method Detail

connect

protected PGProtocol connect(Properties info)
Description copied from class: PGConnection
Open a connection.

Specified by:
connect in class PGConnection

doFunctionCall

Object doFunctionCall(long funcOid,
                      String src,
                      Object[] paramObject,
                      AbstractType rt,
                      AbstractType[] at)
                throws SQLException,
                       IOException
SQLException
IOException

exec

public PGFuncResult exec(long funcOid,
                         byte[][] param)
Overrides:
exec in class PGConnection

exec

public PGExecResult exec(String sql)
Overrides:
exec in class PGConnection

findFunc

public PGFunc[] findFunc(long funcOid,
                         int argLen)
                  throws SQLException
Description copied from class: PGConnection
Find a PostgreSQL function by oid and parameter list length.

Overrides:
findFunc in class PGConnection
Returns:
a zero length array if the function is not found, or a one length array if it is.
SQLException

getTransactionIsolation

public int getTransactionIsolation()
                            throws SQLException
Description copied from class: AbstractConnection
Get the transaction isolation level.

Specified by:
getTransactionIsolation in interface Connection
Overrides:
getTransactionIsolation in class PGConnection
Returns:
TRANSACTION_NONE.
Throws:
SQLException - if a database error occurs

getTypeFromOid

AbstractType getTypeFromOid(long oid)
                      throws IOException
Get the AbstractType for an oid. If the oid is known already, return the cached type. If not, send down the query for the type to the backend and prepare the results.

IOException

internalConnection

public static IntConnection internalConnection()

manageComment

void manageComment(IntProtocol.CommentQuery q)
             throws IOException
IOException

manageConnect

void manageConnect(IntProtocol.ConnectQuery q)
             throws IOException
IOException

manageFunctionCall

void manageFunctionCall(IntProtocol.FunctionCallQuery q)
                  throws IOException
High level communcation function to execute a locally known function and return its result.

IOException

prepareClassLoader

void prepareClassLoader()
                  throws IOException
IOException

queryType

IntProtocol.Type queryType(long oid)
                     throws IOException
High level communication function for querying pg_type given the oid.

IOException

run

public void run()
Specified by:
run in interface Runnable

setCopyInStream

public void setCopyInStream(InputStream in)

setCopyOutStream

public void setCopyOutStream(OutputStream out)

jxDBCon 0.9z

Copyright © 2001,2002 Keve Müller; see LICENSE file for details.