jxDBCon 0.9z

org.sourceforge.jxdbcon
Class AbstractConnection

java.lang.Object
  |
  +--org.sourceforge.jxdbcon.AbstractConnection
All Implemented Interfaces:
Cloneable, Connection, InfoKeys
Direct Known Subclasses:
DB2Connection, PGConnection

public abstract class AbstractConnection
extends Object
implements Cloneable, Connection, InfoKeys

The main class for all database connection implementations.
When subclassing, the following must be defined:

Version:
$Revision: 1.10 $, $Date: 2002/03/16 01:26:07 $
Author:
Keve Müller

Field Summary
protected  Properties info
          The properties used to create the connection.
protected  Map typeMap
          The type map.
protected  SQLWarning warning
          The warnings.
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Fields inherited from interface org.sourceforge.jxdbcon.InfoKeys
CATALOG, DESCRIPTION, DRIVER, HOST, PASSWORD, PORT, SUBDRIVER, USER
 
Constructor Summary
protected AbstractConnection()
          Construct the connection object.
 
Method Summary
 void clearWarnings()
          Null the warnings.
 Object clone()
          Clone this connection.
 void close()
          Close the connection.
 void commit()
          Commit work.
 Statement createStatement()
          Create a statement.
abstract  Statement createStatement(int resultSetType, int resultSetConcurrency)
          Create a statement.
 Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          resultSetHoldability parameter is ignored.
static AbstractConnection duplicate(AbstractConnection conn, String newURL, Properties newInfo)
          Duplicate a connection.
protected  void fillPropertyInfo(ArrayList pi, Properties info)
          Fill the given list with the DriverPropertyInfo structures recognized by the driver.
 void finalize()
          Close the connection, if it was left open.
 boolean getAutoCommit()
          Get the auto commit state.
 String getCatalog()
          Get the current catalog.
protected abstract  EscapeContext getEscapeContext(Object paramBuf, ConversionContext paramContext)
          Create an EscapeContext.
 int getHoldability()
          Not supported.
 Properties getInfo()
          Get the connection information.
 int getTransactionIsolation()
          Get the transaction isolation level.
 Map getTypeMap()
          Get the connection's type map.
 SQLWarning getWarnings()
          Get the warning instance.
 boolean isClosed()
          Retrieves whether this Connection object has been closed
 boolean isReadOnly()
          Get the read only state.
 String nativeSQL(String sql)
          Converts the given SQL statement into the system's native SQL grammar, process JDBC escapes.
protected  void open(String url, Properties info)
          Open the connection.
 CallableStatement prepareCall(String sql)
          Prepare a call.
abstract  CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
           
 CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          resultSetHoldability parameter is ignored.
 PreparedStatement prepareStatement(String sql)
          Prepare a statement.
 PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
          autoGeneratedKeys parameter is ignored.
 PreparedStatement prepareStatement(String sql, int[] columnIndexes)
          columnIndexes parameter is ignored.
abstract  PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
           
 PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          resultSetHoldability parameter is ignored.
 PreparedStatement prepareStatement(String sql, String[] columnNames)
          columnNames parameter is ignored.
 void releaseSavepoint(Savepoint savepoint)
          Not supported.
 void rollback()
          Rollback work.
 void rollback(Savepoint savepoint)
          Not supported.
 void setAutoCommit(boolean autoCommit)
          Set the auto commit state.
 void setCatalog(String catalog)
          Set the current catalog.
 void setHoldability(int holdability)
          Not supported.
 void setReadOnly(boolean readOnly)
          Set the read only state.
 Savepoint setSavepoint()
          Not supported.
 Savepoint setSavepoint(String name)
          Not supported.
 void setTransactionIsolation(int level)
          Set the transaction isolation level.
 void setTypeMap(Map map)
          Set the connection's type map.
protected  void takeOver(AbstractConnection conn)
          Take over the connection to the dbms created by a different instance.
 String toString()
          Format the connection's properties into a String.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.sql.Connection
getMetaData
 

Field Detail

info

protected Properties info
The properties used to create the connection. A null value indicates that the connection was closed.


typeMap

protected Map typeMap
The type map.

See Also:
getTypeMap()

warning

protected SQLWarning warning
The warnings.

See Also:
getWarnings()
Constructor Detail

AbstractConnection

protected AbstractConnection()
Construct the connection object.

Method Detail

clearWarnings

public final void clearWarnings()
Null the warnings.

Specified by:
clearWarnings in interface Connection

clone

public final Object clone()
                   throws CloneNotSupportedException
Clone this connection. The cloned connection will use a new stream to the dbms.

Overrides:
clone in class Object
CloneNotSupportedException

close

public void close()
           throws SQLException
Close the connection. Null everything. This function is implicitely invoked on an open Connection when it gets finalized.

Specified by:
close in interface Connection
Throws:
SQLException - if an error occurs

commit

public void commit()
            throws SQLException
Commit work. Do nothing, we default to auto commit mode.

Specified by:
commit in interface Connection
Throws:
SQLException - if a database error occurs

createStatement

public Statement createStatement()
                          throws SQLException
Create a statement. Creates a FORWARD_ONLY, READ_ONLY statement.

Specified by:
createStatement in interface Connection
SQLException

createStatement

public abstract Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws SQLException
Create a statement. Connection implementations override this.

Specified by:
createStatement in interface Connection
SQLException

createStatement

public Statement createStatement(int resultSetType,
                                 int resultSetConcurrency,
                                 int resultSetHoldability)
                          throws SQLException
resultSetHoldability parameter is ignored.

Specified by:
createStatement in interface Connection
SQLException

duplicate

public static AbstractConnection duplicate(AbstractConnection conn,
                                           String newURL,
                                           Properties newInfo)
                                    throws SQLException
Duplicate a connection.

SQLException

fillPropertyInfo

protected void fillPropertyInfo(ArrayList pi,
                                Properties info)
Fill the given list with the DriverPropertyInfo structures recognized by the driver.


finalize

public final void finalize()
                    throws Throwable
Close the connection, if it was left open.

Overrides:
finalize in class Object
Throwable
See Also:
close()

getAutoCommit

public boolean getAutoCommit()
Get the auto commit state.

Specified by:
getAutoCommit in interface Connection
Returns:
true.

getCatalog

public final String getCatalog()
Get the current catalog.

Specified by:
getCatalog in interface Connection
Returns:
the info property CATALOG, null if not set.

getEscapeContext

protected abstract EscapeContext getEscapeContext(Object paramBuf,
                                                  ConversionContext paramContext)
Create an EscapeContext.


getHoldability

public int getHoldability()
                   throws SQLException
Not supported.

Specified by:
getHoldability in interface Connection
Returns:
the holdability
Throws:
SQLException - if a database error occurs

getInfo

public final Properties getInfo()
Get the connection information.


getTransactionIsolation

public int getTransactionIsolation()
                            throws SQLException
Get the transaction isolation level.

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

getTypeMap

public final Map getTypeMap()
Get the connection's type map.

Specified by:
getTypeMap in interface Connection
Returns:
the connection's typemap.

getWarnings

public final SQLWarning getWarnings()
Get the warning instance.

Specified by:
getWarnings in interface Connection
Returns:
the warning instance

isClosed

public final boolean isClosed()
Retrieves whether this Connection object has been closed

Specified by:
isClosed in interface Connection
Returns:
the connection's open state.

isReadOnly

public boolean isReadOnly()
Get the read only state.

Specified by:
isReadOnly in interface Connection
Returns:
false

nativeSQL

public String nativeSQL(String sql)
                 throws SQLException
Converts the given SQL statement into the system's native SQL grammar, process JDBC escapes.

Specified by:
nativeSQL in interface Connection
Parameters:
sql - the sql statement
Returns:
the processed statement in native grammar
Throws:
SQLException - if a database error occurs

open

protected void open(String url,
                    Properties info)
             throws SQLException
Open the connection. The info properties contain all supplied information, the url should be passed on to the metadata instance without looking at it.

SQLException

prepareCall

public CallableStatement prepareCall(String sql)
                              throws SQLException
Prepare a call. Prepares a TYPE_FORWARD_ONLY, CONCUR_READ_ONLY call.

Specified by:
prepareCall in interface Connection
SQLException

prepareCall

public abstract CallableStatement prepareCall(String sql,
                                              int resultSetType,
                                              int resultSetConcurrency)
                                       throws SQLException
Specified by:
prepareCall in interface Connection
SQLException

prepareCall

public CallableStatement prepareCall(String sql,
                                     int resultSetType,
                                     int resultSetConcurrency,
                                     int resultSetHoldability)
                              throws SQLException
resultSetHoldability parameter is ignored.

Specified by:
prepareCall in interface Connection
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql)
                                   throws SQLException
Prepare a statement. Prepares a TYPE_FORWARD_ONLY, CONCUR_READ_ONLY statement.

Specified by:
prepareStatement in interface Connection
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
                                   throws SQLException
autoGeneratedKeys parameter is ignored.

Specified by:
prepareStatement in interface Connection
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int[] columnIndexes)
                                   throws SQLException
columnIndexes parameter is ignored.

Specified by:
prepareStatement in interface Connection
SQLException

prepareStatement

public abstract PreparedStatement prepareStatement(String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws SQLException
Specified by:
prepareStatement in interface Connection
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int resultSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
                                   throws SQLException
resultSetHoldability parameter is ignored.

Specified by:
prepareStatement in interface Connection
SQLException

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          String[] columnNames)
                                   throws SQLException
columnNames parameter is ignored.

Specified by:
prepareStatement in interface Connection
SQLException

releaseSavepoint

public void releaseSavepoint(Savepoint savepoint)
                      throws SQLException
Not supported.

Specified by:
releaseSavepoint in interface Connection
Parameters:
savepoint - The Savepoint
Throws:
SQLException - if a database error occurs

rollback

public void rollback()
              throws SQLException
Rollback work. Not supported, we defaulted to auto commit mode.

Specified by:
rollback in interface Connection
Throws:
SQLException - if a database error occurs

rollback

public void rollback(Savepoint savepoint)
              throws SQLException
Not supported.

Specified by:
rollback in interface Connection
Parameters:
savepoint - The Savepoint
Throws:
SQLException - if a database error occurs

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws SQLException
Set the auto commit state. Throw an exception if not autocommit mode is requested.

Specified by:
setAutoCommit in interface Connection
Parameters:
autoCommit - the desired auto commit mode
Throws:
SQLException - if a database error occurs

setCatalog

public void setCatalog(String catalog)
                throws SQLException
Set the current catalog. Default behaviour is to silently ignore this request, thus not supporting catalogs.

Specified by:
setCatalog in interface Connection
Parameters:
catalog - the new catalog
Throws:
SQLException - if a database error occurs

setHoldability

public void setHoldability(int holdability)
                    throws SQLException
Not supported.

Specified by:
setHoldability in interface Connection
Parameters:
holdability - the holdability
Throws:
SQLException - if a database error occurs

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws SQLException
Set the read only state. Request read/only not supported.

Specified by:
setReadOnly in interface Connection
Parameters:
readOnly - the desired read only state
Throws:
SQLException - if a database error occurs

setSavepoint

public Savepoint setSavepoint()
                       throws SQLException
Not supported.

Specified by:
setSavepoint in interface Connection
Returns:
the Savepoint object
Throws:
SQLException - if a database error occurs

setSavepoint

public Savepoint setSavepoint(String name)
                       throws SQLException
Not supported.

Specified by:
setSavepoint in interface Connection
Parameters:
name - The Savepoint's name
Returns:
the Savepoint object
Throws:
SQLException - if a database error occurs

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws SQLException
Set the transaction isolation level. Anything but TRANSACTION_NONE is not supported.

Specified by:
setTransactionIsolation in interface Connection
Parameters:
level - the desired isolation level
Throws:
SQLException - if a database error occurs

setTypeMap

public final void setTypeMap(Map map)
Set the connection's type map.

Specified by:
setTypeMap in interface Connection
Parameters:
map - the new type map

takeOver

protected void takeOver(AbstractConnection conn)
                 throws SQLException
Take over the connection to the dbms created by a different instance.

SQLException

toString

public String toString()
Format the connection's properties into a String.

Overrides:
toString in class Object
Returns:
a verbose description of the connections properties

jxDBCon 0.9z

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