|
soap tutorial | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectadriani.jws.template.db.MockConnection
public class MockConnection
Wrapper class for the java.sql.Connection
object. These wrappers can be pooled using the
MockConnectionPool
class, in substitution of the couple "pure connections" pooled by the
simple JDBCConnectionPool
class.
Usually it should be not necessary to use these wrappers, since the JDBC connection pool guarantees the
same behavior and performances. Selecting this "pool wrapper architecture" could be the best choice only
in few situations, such as:
MockConnection
class.MockConnection
wrapper class, and retrieved even after execution.
Field Summary | |
---|---|
protected java.sql.Connection |
connection
The JDBC SQL connection object wrapped by this class. |
protected static java.lang.String |
leadingName
Beginning of each logging message produced by this class. |
protected static WSLogger |
logger
Retrieving the logger instance to be used for this class. |
Constructor Summary | |
---|---|
MockConnection(java.sql.Connection connection)
Standard constructor. |
|
MockConnection(java.lang.String alias,
java.lang.String usr,
java.lang.String pwd)
Use this constructor if another class has already registered the JDBC driver for the same type of database hosting these connections. |
Method Summary | |
---|---|
java.sql.Connection |
getConnection()
Accessor method. |
java.sql.PreparedStatement |
getPreparedStatement(java.lang.String query)
Use always this method to create a JDBC PreparedStatement from a xxxDAO
class, in order to uncouple database pooling structure from DAO query logic. |
boolean |
returnPreparedStatement(java.sql.PreparedStatement pstmt)
Use always this method to close a JDBC PreparedStatement from a xxxDBA
class, in order to uncouple database pooling structure from DBA query logic. |
void |
setConnection(java.sql.Connection connection)
Mutator method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.sql.Connection connection
protected static java.lang.String leadingName
protected static WSLogger logger
Constructor Detail |
---|
public MockConnection(java.sql.Connection connection)
connection
- the java.sql.Connection
to be wrapped by this classpublic MockConnection(java.lang.String alias, java.lang.String usr, java.lang.String pwd)
DriverManager
and stores it as a class field.
alias
- the tns string of the db, e.g. jdbc:oracle:thin:@192.168.1.10:1533:my_databaseusr
- the user name for the connectionpwd
- the password for the connectionMethod Detail |
---|
public java.sql.PreparedStatement getPreparedStatement(java.lang.String query) throws java.sql.SQLException
PreparedStatement
from a xxxDAO
class, in order to uncouple database pooling structure from DAO query logic.Database
class and then decide if the prepared
statement must be produced brand new, or retrieved from the inner cache.
query
- the original SQL query, filled with question marks ('?') characters
java.sql.SQLException
GeneralDAO
,
returnPreparedStatement(PreparedStatement pstmt)
public boolean returnPreparedStatement(java.sql.PreparedStatement pstmt)
PreparedStatement
from a xxxDBA
class, in order to uncouple database pooling structure from DBA query logic.Database
class and then decide if the prepared
statement must be closed or cached in this class's inner hashtable.
pstmt
- the PreparedStatement
obtained using getPreparedStatement()
true
if the prepared statement has been closed (i.e. released)GeneralDAO
,
getPreparedStatement(String query)
public void setConnection(java.sql.Connection connection)
public java.sql.Connection getConnection()
|
Build 18/09/2012 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |