|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sourceforge.esw.collection.ATransducer | +--net.sourceforge.esw.collection.AJDBCTransducer
Performs transduction between a JDBC data source and an
IMetaCollection
instance.
This transduction occurs both ways; put()
takes data
from the IMetaCollection
instance to which this
ITransducer
instance is attached and places it into the data
source represented by this ITransducer
instance. The
get()
method takes data from the data source represented by this
ITransducer
instance and places it into the
IMetaCollection
instance to which this ITransducer
instance is attached.
To enable transactional considerations, one must first call the
setAutoCommit
method passing in true
. Otherwise,
the default get
or put
code will automatially
commit during their execution.
This AJDBCTransducer
instance abstracts the JDBC connection
methods and some convience methods for interacting with the JDBC data source.
This AJDBCTransducer
instance pools the connections to the JDBC
data source. See the
net.sourceforge.esw.util.database.DBConnectionPoolManager
class for
more details of how to use the pooling outside of the
AJDBCTransducer
.
DBConnectionPoolManager
,
IMetaCollection
,
INodeContextFactory
, Serialized FormField Summary | |
protected boolean |
bJDBCDriverAutoCommit
The ITransactionalTransducer JDBC Driver autocommit property. |
protected boolean |
bTransducerAutoCommit
The ITransactionalTransducer autocommit property. |
protected java.sql.Connection |
connection
For non-AutoCommit mode, the Connection reference to commit or rollback when the transaction is complete or aborted. |
static java.lang.String |
DELIMITER
The delimiter used for replaceable parameters. |
protected java.lang.String |
password
The password for the authorized JDBC data source user. |
protected static java.lang.String |
QUESTION
The ? character for Prepared Staements and Stored Procedures. |
protected java.lang.String |
url
The URL for the JDBC data source. |
protected java.lang.String |
userid
The User id for the authorized JDBC data source user. |
Fields inherited from class net.sourceforge.esw.collection.ATransducer |
contextFactory |
Constructor Summary | |
AJDBCTransducer(java.lang.String aDriver,
java.lang.String aURL)
Creates a new AJDBCTransducer instance with all the JDBC
paramters neccessary to create a JDBC connection. |
|
AJDBCTransducer(java.lang.String aDriver,
java.lang.String aURL,
java.lang.String aUser,
java.lang.String aPassword)
Creates a new AJDBCTransducer instance with all the JDBC
parameters neccessary to create a JDBC connection. |
Method Summary | |
void |
commit()
Commits any get or put invocation up to the
last (if any) commit previously invoked. |
boolean |
getAutoCommit()
Returns whether any get or put invocations will
automatically commit during their execution. |
protected java.sql.Connection |
getConnection()
Returns a new Connection from the DB Connection Pooling. |
boolean |
getJDBCDriverAutoCommit()
Returns whether any get or put invocations will
automatically commit during their execution. |
protected java.util.List |
getReplaceableParameterNames(java.lang.String aStatement,
java.lang.String aDelimiters)
Returns the names of the replaceable parameters from the specified statement using the specified delimiters. |
protected void |
putResultSetIntoMetaCollection(java.sql.ResultSet aResultSet,
IMetaCollection aCollection)
Puts the specified ResultSet instance into the specified
IMetaCollection instance. |
protected java.lang.String |
removeReplaceableParameters(java.lang.String aStatement,
java.lang.String aDelimiters)
Removes the replaceable parameters from the specified statement and replaces them with ?'s. |
void |
rollback()
Rolls back any get or put invocation up to the
last (if any) rollback previously invoked. |
void |
setAutoCommit(boolean aAutoCommit)
Sets whether any get or put invocations will
automatically commit during their execution. |
void |
setJDBCDriverAutoCommit(boolean aAutoCommit)
Sets whether any get or put invocations will
automatically commit during their execution. |
void |
setLog(boolean aLog)
Sets if this AJDBCTransducer instance will log JDBC calls to
System.out . |
Methods inherited from class net.sourceforge.esw.collection.ATransducer |
getContextFactory, setContextFactory |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sourceforge.esw.collection.ITransducer |
get, getContextFactory, put, setContextFactory |
Field Detail |
protected java.lang.String url
protected java.lang.String userid
protected java.lang.String password
protected boolean bJDBCDriverAutoCommit
ITransactionalTransducer
JDBC Driver autocommit property.
The default is true.protected boolean bTransducerAutoCommit
ITransactionalTransducer
autocommit property. The default
is true.protected java.sql.Connection connection
protected static final java.lang.String QUESTION
public static final java.lang.String DELIMITER
Constructor Detail |
public AJDBCTransducer(java.lang.String aDriver, java.lang.String aURL, java.lang.String aUser, java.lang.String aPassword) throws java.lang.IllegalArgumentException
AJDBCTransducer
instance with all the JDBC
parameters neccessary to create a JDBC connection.aDriver
- the fully-qualified JDBC Driver class name.aURL
- the URL for the JDBC driver.aUser
- the authorized user for the JDBC data source.aPassword
- the password for the authoized user.java.lang.IllegalArgumentException
- if the JDBC driver does not exist or
does not properly register.public AJDBCTransducer(java.lang.String aDriver, java.lang.String aURL) throws java.lang.IllegalArgumentException
AJDBCTransducer
instance with all the JDBC
paramters neccessary to create a JDBC connection.aDriver
- the fully-qualifed JDBC Driver class name.aURL
- the URL for the JDBC driver.java.lang.IllegalArgumentException
- if the JDBC driver does not exist or
does not properly register.Method Detail |
public void setLog(boolean aLog)
AJDBCTransducer
instance will log JDBC calls to
System.out
.aLog
- if true
, will log JDBC calls from the driver.public void commit() throws TransducerException
get
or put
invocation up to the
last (if any) commit previously invoked. This method must be called to
complete the trnasduction if the setAutoCommit
is set to
true
.commit
in interface ITransactionalTransducer
net.sourceforge.esw.collection.ITransactionalTransducer
TransducerException
- if an error occurred during the commit
process.public void rollback() throws TransducerException
get
or put
invocation up to the
last (if any) rollback previously invoked.rollback
in interface ITransactionalTransducer
net.sourceforge.esw.collection.ITransactionalTransducer
TransducerException
- if an error occurred during the rollback
process.public boolean getJDBCDriverAutoCommit()
get
or put
invocations will
automatically commit during their execution.public boolean getAutoCommit()
get
or put
invocations will
automatically commit during their execution. This commit will occur after
the entire put or get operation is complete.public void setJDBCDriverAutoCommit(boolean aAutoCommit)
get
or put
invocations will
automatically commit during their execution.aAutoCommit
- if true
, will set the JDBC Driver to
automatically commit the transduction during
get
or put
execution. If
false
, then commit
must be
called to complete the transduction.public void setAutoCommit(boolean aAutoCommit)
get
or put
invocations will
automatically commit during their execution. This commit will occur after
the entire put or get operation is complete. If the autocommit for the
JDBC driver is set to true, then setting the Transducer Autocommit to true
will set the driver Autocommit to false.setAutoCommit
in interface ITransactionalTransducer
aAutoCommit
- if true
, will automatically commit the
transduction at the end of get
or
put
execution. If false
, then
commit
must be called to complete the
transduction.protected java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException
- if an error occurs while getting the connection.protected void putResultSetIntoMetaCollection(java.sql.ResultSet aResultSet, IMetaCollection aCollection) throws java.sql.SQLException
ResultSet
instance into the specified
IMetaCollection
instance.aResultSet
- the ResultSet
instance that contains the
data being transduced into the specified
IMetaCollection
instance.aCollection
- the IMetaCollection
instance that the
specified ResultSet
instance will be
transduced.java.lang.Exception
- if an error occurs during the transduction.protected java.util.List getReplaceableParameterNames(java.lang.String aStatement, java.lang.String aDelimiters)
aStatement
- a SQL statement from which to peel the names of the
replaceable parameters.aDelimiters
- the delimiters used for the replaceable parameters.INode
instances.protected java.lang.String removeReplaceableParameters(java.lang.String aStatement, java.lang.String aDelimiters)
aStatement
- a SQL statement from which to remove the replaceable
parameters.aDelimiters
- the delimiters used for the replaceable parameters.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |