|
soap tutorial | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectadriani.jws.template.db.GeneralDAO
adriani.jws.template.db.ServiceDAO
public class ServiceDAO
The class wrapping all the SQL queries and statement necessary to retrieve data from the database(s).
This class stores the necessary references to the database connections. These fields are not present in the
GeneralDAO
parent class because usually it's better to avoid storing DB connection as class fields.
Here we store the connections to improve performances by sharing the same connection only when invoking
a sequence of queries from the ServiceMacro
, usually during the same SOAP call.
The connections are obtained from the Database
class using the MockConnection
wrapper, which allows to perform some specific test/debug operations and could improve performances when
using prepared statements in a connection pooling environment.
Note that it's up to the Database
class to manage the connections pooling (if used), in order
to keep uncoupled the implementation of this class from the management of connections:
no matter which pool class is used, a DAO class should always retrieve connections just calling:
Database.getMockConnection(targetDB)
and returning them by calling:
Database.returnMockConnection(targetDB, this.mock[targetDB])
Field Summary | |
---|---|
protected static java.lang.String |
GET_CUSTOMER
SAMPLE query in string format used to create the corresponding prepared statement. |
protected static java.lang.String |
GET_ENTITY_TIME
SAMPLE query in string format used to create the corresponding prepared statement. |
protected static WSLogger |
logger
Retrieving the logger instance to be used for this class. |
protected MockConnection[] |
mock
The array of mock connections for the necessary database(s) (accessed by this DAO). |
protected static java.lang.StringBuffer |
ONE
Static final String value stored as class fields to improve performances. |
protected ServiceMacro |
serviceMacro
A reference to the ServiceMacro object which created this DA0. |
Fields inherited from class adriani.jws.template.db.GeneralDAO |
---|
AUTO, chronStart, db_timestamp, DOUBLE_QUOTES, EMPTY, ERROR, leadingName, NO_DATA_FOUND, NO_DATA_MSG, PERCENT, PSTMT_NOK, QUERY_NOK, QUOTE, ROLLBACK_NOK, status, VARCHAR |
Constructor Summary | |
---|---|
ServiceDAO()
This constructor DOES NOT require (nor create) the serviceMacro object, hence the
configuration files and properties will NOT be loaded. |
|
ServiceDAO(ServiceMacro macro)
Stateful constructor. |
Method Summary | |
---|---|
void |
closeConnection(int targetDB)
Close the connection specified by the input target parameter, for example: targetDB = DB_01 --> close the connection to the DB_01 database. |
void |
collectStatus(int statusValue)
We override the parent (empty) method in order to register the execution status of a general SQL statement in the ServiceAnalyzer class, by calling:serviceMacro.getServiceAnalyzer().collect(status) ; |
java.sql.Connection |
getConnection(int targetDB)
Return the connection currently opened through the target database, for example: targetDB = DB_01 --> close the connection to the DB_01 database. |
CustomerDTO[] |
getCustomerData(java.lang.StringBuffer number,
java.lang.StringBuffer customer)
Sample basic query: remove this method when developing actual DAO method. |
java.lang.StringBuffer[][] |
getDummyQuery(java.lang.StringBuffer[] param,
int howMany,
int cols)
Produces a StringBuffer[][] object created from some hard-coded data for a general
SOAP method. |
EntityTimeDTO |
getEntityTime(int id)
Sample basic query: remove this method when developing actual DAO method. |
boolean |
openConnection(int targetDB)
Open the connection to the target database. |
java.lang.StringBuffer |
testPreparedStatement(int number)
Dummy query used to test the mocked pool mechanism if there is not any query using the prepared statement approach. |
Methods inherited from class adriani.jws.template.db.GeneralDAO |
---|
compareSB, doubleQuote, endQuery, executeUpdate, executeUpdate, fetchColumnData, finalize, flushLogger, getColumnData, getColumnType, getFunction, getFunction, getFunctionPipe, getPreparedRecord, getPreparedRecordSet, getProcedure, getRecord, getRecord, getRecordSet, getRecordSet, getRowCount, getStatus, inspectColumn, inspectResultSet, quote, startQuery, valueOfString, valueOfTimestamp |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected MockConnection[] mock
protected ServiceMacro serviceMacro
ServiceMacro
object which created this DA0.
protected static final java.lang.String GET_CUSTOMER
protected static final java.lang.String GET_ENTITY_TIME
protected static final java.lang.StringBuffer ONE
String
value stored as class fields to improve performances.
protected static WSLogger logger
Constructor Detail |
---|
public ServiceDAO()
serviceMacro
object, hence the
configuration files and properties will NOT be loaded. Default values (hard coded) will be used
instead, as defined in the Settings
class.
public ServiceDAO(ServiceMacro macro)
macro
- the ServiceMacro
class creating and using this DAOMethod Detail |
---|
public boolean openConnection(int targetDB)
targetDB
parameter, for example:Database
class using the getMockConnection
mechanism, which allowS to retrieve both simple connections or wrapped connections.false
. Usually this means that
the web service will not produce a valid response: the client could receive a SOAP response
containing a message like "database not found".
targetDB
- the reference code of the database where to open the connection
true
if the connection has been opened successfullyDatabase.getMockConnection(int targetDB)
public void closeConnection(int targetDB)
targetDB
- the number of the database where to return the connectionpublic java.sql.Connection getConnection(int targetDB)
getConnection
in class GeneralDAO
targetDB
- the number of the database offering the connection
public CustomerDTO[] getCustomerData(java.lang.StringBuffer number, java.lang.StringBuffer customer)
number
- the whole telephone number (without the international prefix)customer
- the customer ID reference number (optional)
public EntityTimeDTO getEntityTime(int id)
id
- the entity id reference
public void collectStatus(int statusValue)
ServiceAnalyzer
class, by calling:serviceMacro.getServiceAnalyzer().collect(status) ;
collectStatus
in class GeneralDAO
statusValue
- the integer status as defined by the ErrorMessage
class fieldsErrorMessage
public java.lang.StringBuffer[][] getDummyQuery(java.lang.StringBuffer[] param, int howMany, int cols)
StringBuffer[][]
object created from some hard-coded data for a general
SOAP method. This method should be used only during development to obtain an output from a SOAP
method as long as the actual database is not available.
param
- the array containing all the input datahowMany
- the number of record to be retrievedcols
- the number of columns for each record
StringBuffer[][]
object obtained from hard-coded datapublic java.lang.StringBuffer testPreparedStatement(int number)
|
Build 18/09/2012 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |