net.xoetrope.optional.data.sql
Class DataConnection

java.lang.Object
  extended by net.xoetrope.optional.data.sql.DataConnection

public class DataConnection
extends java.lang.Object

An extended database connection that allows integration of a local database and replication to/from a remote database.

Copyright (c) Xoetrope Ltd. 2001-2004

$Revision: 2.11 $ License: see license.txt


Constructor Summary
DataConnection(java.lang.String name)
          Construct a new connection
DataConnection(java.lang.String name, boolean replicate)
          Construct a new connection
 
Method Summary
 ConnectionObject borrowConnection()
          Borrow the connection object
 java.sql.PreparedStatement createPreparedStatement(java.lang.String sql, java.lang.String connName)
          Create a prepared statement.
 java.sql.ResultSet executeQuery(java.lang.String sql)
          Execute a SQL query
 java.sql.ResultSet executeQuery(java.lang.String sql, java.lang.String connName, boolean writable)
          Execute a SQL query.
 int executeUpdate(java.lang.String sql)
          Execute a SQL update statement.
 java.sql.ResultSet getMetaData(java.lang.String tableName)
          Get a list of the fields in a table.
 void returnConnection()
          Return the connection object to the pool
 void returnPreparedStatement(java.sql.PreparedStatement ps)
          Create a prepared statement.
static void shutdown(java.lang.String connParamName)
          Execute a SHUTDOWN statement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataConnection

public DataConnection(java.lang.String name)
Construct a new connection

Parameters:
name - the connection name

DataConnection

public DataConnection(java.lang.String name,
                      boolean replicate)
Construct a new connection

Parameters:
name - the connection name
replicate - true to attempt use of the replication service
Method Detail

executeUpdate

public int executeUpdate(java.lang.String sql)
                  throws java.lang.Exception
Execute a SQL update statement.

Parameters:
sql - the SQL statement to be executed
Returns:
the result of the update query
Throws:
java.lang.Exception

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sql)
                                throws java.sql.SQLException
Execute a SQL query

Parameters:
sql - the SQL statement to be executed
Returns:
the result of the query statement
Throws:
java.sql.SQLException

executeQuery

public java.sql.ResultSet executeQuery(java.lang.String sql,
                                       java.lang.String connName,
                                       boolean writable)
                                throws java.sql.SQLException
Execute a SQL query.

Parameters:
sql - the SQL statement
connName - the connection name
writable - true to attempt to create an updatable resultset
Returns:
the results of the query
Throws:
java.sql.SQLException

createPreparedStatement

public java.sql.PreparedStatement createPreparedStatement(java.lang.String sql,
                                                          java.lang.String connName)
                                                   throws java.sql.SQLException
Create a prepared statement. Note that you MUST release the PreparedStatement by calling returnPreparedStatement when finished with the statement

Parameters:
sql - the SQL statement
connName - the connection name
Returns:
the PreparedStatement
Throws:
java.sql.SQLException

returnPreparedStatement

public void returnPreparedStatement(java.sql.PreparedStatement ps)
Create a prepared statement. Note that you MUST release the PreparedStatement by calling returnPreparedStatement when finished with the

Parameters:
ps - the PreparedStatement to be retrived

getMetaData

public java.sql.ResultSet getMetaData(java.lang.String tableName)
Get a list of the fields in a table.

Parameters:
tableName - the table name
Returns:
the meta data result set

borrowConnection

public ConnectionObject borrowConnection()
                                  throws java.sql.SQLException
Borrow the connection object

Returns:
the connection object
Throws:
java.sql.SQLException

returnConnection

public void returnConnection()
Return the connection object to the pool


shutdown

public static void shutdown(java.lang.String connParamName)
                     throws java.lang.Exception
Execute a SHUTDOWN statement

Parameters:
connParamName - the name of the connection on which the shutdown statement is executed, or null for the default connection
Throws:
java.lang.Exception