|
soap tutorial | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectadriani.jws.template.db.Database
public class Database
The data-bridge class used to retrieve and return JDBC connection from the database. To obtain a connection,
users should use a code block like this:
Connection connection = Database.getMockConnection(targetDB) ;
// Perform your SQL operations here
Database.returnMockConnection(targetDB, this.mock[targetDB]) ;
MockConnection
, which in general is not
actually a mock connection, but it's just a wrapper for a normal java SQL connection.Database.DB_01
, Database.DB_02
labels and the
Database.DB_NUMBER parameter.
Field Summary | |
---|---|
static int |
DB_01
Reference code for the DB_01 database. |
static int |
DB_02
Reference code for the DB_02 database (Placeholder) |
static int |
DB_NUMBER
Total number of databases handled by this class. |
protected static java.lang.String |
driver
Name of the current JDBC driver (for testing or debug). |
static java.lang.String |
jdbc_prefix
The JDBC prefix used to build the complete connect string. |
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. |
protected static int |
maximum
Maximum allowed number of connections for ALL the JDBC pools. |
protected static boolean |
mock
Specifies if connections are retrieved from a pure JDBC pool (the JDBCConnectionPool class)
or from a mocked connection pool (the MockConnectionPool class). |
protected static JDBCConnectionPool[] |
pool
Array of JDBC connection pool for the databases handled by this class. |
protected static int |
timeout
Sleep time for the cleaning thread for ALL the JDBC pools (in seconds). |
protected static java.lang.String |
tns_property
Name of the Java Property where to set the reference to the tnsnames.ora file. |
protected static java.lang.String |
tnsnames
Absolute path of the tnsnames.ora (if used). |
Constructor Summary | |
---|---|
Database()
|
Method Summary | |
---|---|
static JDBCConnectionPool |
getJDBCPool(int targetDB)
Return the JDBCConnectionPool object managing all the JDBC connections to the database
specified in input, according to the static fields reference defined by this class. |
static java.lang.StringBuffer |
getMetaData(java.sql.Connection connection)
Produce the meta-data information about the input database's connection object and format this data into a StringBuffer object. |
static MockConnection |
getMockConnection(int targetDB)
Return a new MockConnection wrapper containing the SQL connection, by retrieving
it from the proper pool (pure or mocked). |
static void |
logMetaData()
Print in the LOG file and on the STDOUT some meta-data information about ALL the databases used by this project. |
static void |
logMetaData(int target)
Print in the LOG file and on the STDOUT some meta-data information about the database selected by the input parameter, according to the static fields reference defined by this class. |
static void |
logPoolsData()
Logs some information about the status of the JDBC pools used by this database class. |
static void |
returnMockConnection(int targetDB,
MockConnection wrapper)
Release an already opened SQL connection, wrapped by a MockConnection object,
returning it in the pool that originally produced such connection. |
static java.lang.StringBuffer |
showMetaData(int target)
Produces a formatted string containing some meta-data information about the database selected by the input target parameter, according to the static fields reference defined by this class. |
static boolean |
usesMockedPool()
Specifies if connections are retrieved from the pure JDBC pool (i.e. the JDBCConnectionPool )
or from the MockConnectionPool . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DB_01
public static final int DB_02
public static final int DB_NUMBER
protected static boolean mock
JDBCConnectionPool
class)
or from a mocked connection pool (the MockConnectionPool
class).
protected static JDBCConnectionPool[] pool
protected static int timeout
protected static int maximum
protected static java.lang.String driver
public static java.lang.String jdbc_prefix
protected static java.lang.String tnsnames
tnsnames.ora
(if used).
protected static java.lang.String tns_property
tnsnames.ora
file.
protected static java.lang.String leadingName
protected static WSLogger logger
Constructor Detail |
---|
public Database()
Method Detail |
---|
public static boolean usesMockedPool()
JDBCConnectionPool
)
or from the MockConnectionPool
. Notice that all other information about the pool (timeout,
maximum limit etc.) can be retrieved by inspecting the proper pool instance as obtained by the method
getJDBCPool(int targetDB)
method.
true
if this class relies on an instance of the MockConnectionPool
,
false
if the standard JDBCConnectionPool
is usedpublic static JDBCConnectionPool getJDBCPool(int targetDB)
JDBCConnectionPool
object managing all the JDBC connections to the database
specified in input, according to the static fields reference defined by this class.JDBCConnectionPool
object or another valid subclass,
for example a MockConnectionPool
class.getJDBCPool(Datase.DB_01)
will return the JDBC pool for the DB_01 database.
targetDB
- a reference to the database (see static class field definitions)
JDBCConnectionPool
for the input databaseusesMockedPool()
,
JDBCConnectionPool
,
MockConnectionPool
public static MockConnection getMockConnection(int targetDB) throws java.sql.SQLException
MockConnection
wrapper containing the SQL connection, by retrieving
it from the proper pool (pure or mocked).
targetDB
- a reference to the database (see static class field definitions)
JDBCConnectionPool
for the input database
java.sql.SQLException
public static void returnMockConnection(int targetDB, MockConnection wrapper)
MockConnection
object,
returning it in the pool that originally produced such connection.
targetDB
- a reference to the database (see static class field definitions)wrapper
- the MockConnection
wrapper to be releasedpublic static void logMetaData()
public static void logMetaData(int target)
logMetaData(Datase.DB_01)
will show meta-data about the DB_01 database.
target
- a reference to the database (see static class field definitions)public static java.lang.StringBuffer showMetaData(int target)
target
parameter, according to the static fields reference defined by this class.showMetaData(Datase.DB_01)
will produce meta-data about the DB_01 database.
target
- a reference to the database (see static class field definitions)public static java.lang.StringBuffer getMetaData(java.sql.Connection connection) throws java.sql.SQLException
StringBuffer
object.
java.sql.SQLException
public static void logPoolsData()
GeneralService.manageService(int key)
|
Build 19/03/2014 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |