Package fr.dyade.aaa.ext
Class JDBCTransaction
- java.lang.Object
-
- fr.dyade.aaa.util.BaseTransaction
-
- fr.dyade.aaa.util.AbstractTransaction
-
- fr.dyade.aaa.util.DBTransaction
-
- fr.dyade.aaa.ext.JDBCTransaction
-
- All Implemented Interfaces:
JDBCTransactionMBean,DBTransactionMBean,Transaction,TransactionMBean
public class JDBCTransaction extends DBTransaction implements JDBCTransactionMBean
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class fr.dyade.aaa.util.AbstractTransaction
AbstractTransaction.Context
-
-
Field Summary
Fields Modifier and Type Field Description private Stringconnurlprivate Stringdbinitprivate Stringdbnamestatic StringDFLT_JDBC_DB_PREFIXprivate Stringdriverprivate Stringhoststatic StringJDBC_CONNECT_RETRY_COUNT_PROPThis property is used to set the number of reconnection attempts after a failure, by default 5.static StringJDBC_CONNECT_RETRY_MAX_PERIOD_PROPThis property is used to set the maximum time trying to reconnect after a failure, by default 60.000 (60 seconds).static StringJDBC_CONNECT_RETRY_MIN_DELAY_PROPThis property is used to set the minimum time between two attempts to reconnect after a failure, by default 1.000 (1 seconds).static StringJDBC_DB_CLOSE_PROPThis property is used to define the SQL statement executed at the end of the module, by default none.static StringJDBC_DB_DELETE_PROPThis property allows to define the SQL statement allowing to delete an entry in the table used by the module, by default: "DELETE FROM <table> WHERE name=?"static StringJDBC_DB_HOST_PROPThis property allows to define the hostname of the URL used to establish the connection.static StringJDBC_DB_INIT_PROPThis property allows to define the SQL statement allowing to create the table used by the module, for example: "CREATE TABLE JoramDB (name VARCHAR(256), content LONG VARCHAR FOR BIT DATA, PRIMARY KEY(name))" This property can be set only at first launching.static StringJDBC_DB_INSERT_PROPThis property allows to define the SQL statement allowing to insert an entry in the table used by the module, by default: "INSERT INTO <table> VALUES (?static StringJDBC_DB_LOAD_PROPThis property allows to define the SQL statement allowing to load an entry from the table used by the module, by default: "SELECT content FROM <table> WHERE name=?"static StringJDBC_DB_NAME_PROPThis property allows to define the database name of the URL used to establish the connection, by default "JoramDB".static StringJDBC_DB_PASS_PROPThis property allows to define the password of database user on whose behalf the connection is being made.static StringJDBC_DB_PORT_PROPThis property allows to define the port of the URL used to establish the connection.static StringJDBC_DB_PROTOCOL_PROPThis property allows to define the protocol part of the URL used to establish the connection, for example "jdbc:mysql".static StringJDBC_DB_UPDATE_PROPThis property allows to define the SQL statement allowing to update an entry in the table used by the module, by default: "UPDATE <table> SET content=?static StringJDBC_DB_USER_PROPThis property allows to define the name of database user on whose behalf the connection is being made.static StringJDBC_DRIVER_PROPThis property allows to define the class that implements the JDBC driver, for example "com.mysql.jdbc.Driver".static StringJDBC_PROPS_FILE_PROPThis property allows to define the name of a file containing a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included.static StringJDBC_TRANSACTION_PREFIXstatic StringJDBC_URL_PROPThis property allows to define the database url of the form "jdbc:subprotocol://host:port/dbname".private Stringpasswordprivate Stringpathprivate Stringportprivate Propertiespropsprivate Stringprotocolprivate Stringuser-
Fields inherited from class fr.dyade.aaa.util.DBTransaction
conn, connectRetryCount, connectRetryMaxPeriod, connectRetryMinDelay, DB_TRANSACTION_PREFIX, dbclose, dbdelete, dbinsert, dbload, dbtable, dbupdate, DFLT_TABLE_PREFIX, JDBC_CONNECT_RETRY_COUNT_DFLT, JDBC_CONNECT_RETRY_MAX_PERIOD_DFLT, JDBC_CONNECT_RETRY_MIN_DELAY_DFLT, TABLE_NAME_PROP
-
Fields inherited from class fr.dyade.aaa.util.AbstractTransaction
average, dir, logmon, MONITOR, OOS_STREAM_HEADER, PERIODS, perThreadContext, phase, startTime
-
Fields inherited from class fr.dyade.aaa.util.BaseTransaction
DEBUG
-
-
Constructor Summary
Constructors Constructor Description JDBCTransaction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconnectDB()This method try to reconnect to the database, it is used in case of failure during commit.protected voiddumpProperties(StringBuilder strbuf)PropertiesgetClientInfo()StringgetDBInitStatement()StringgetDBName()StringgetDriver()StringgetPropertiesPath()StringgetURL()StringgetUser()protected voidinitDB()Instantiates the database driver and creates the table if necessary-
Methods inherited from class fr.dyade.aaa.util.DBTransaction
backup, close, commit, delete, dumpProperties, getBadInserts, getBadUpdates, getCommitBytes, getCommitCount, getDBCloseStatement, getDBDeleteStatement, getDBInsertStatement, getDBLoadStatement, getDBTableName, getDBUpdateStatement, getFromLog, getList, getLogThresholdOperation, getNbDeletes, getNbInserts, getNbUpdates, getPersistenceDir, initRepository, loadAll, loadByteArray, saveInLog, setPhase, stop, useLoadAll
-
Methods inherited from class fr.dyade.aaa.util.AbstractTransaction
begin, containsOperations, create, create, createByteArray, createByteArray, delete, getAverageCommitTime, getOperationCount, getPhase, getPhaseInfo, getStartTime, init, isPersistent, load, load, loadByteArray, loadFromByteArray, release, save, save, save, saveByteArray, saveByteArray, saveByteArray
-
Methods inherited from class fr.dyade.aaa.util.BaseTransaction
dumpObjectList, freeze, getBoolean, getInteger, getInteger, getObject, getObjectList, getProperty, getProperty, loadProperties, saveProperties
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fr.dyade.aaa.util.DBTransactionMBean
dumpProperties, getAverageCommitTime, getBadInserts, getBadUpdates, getCommitBytes, getDBCloseStatement, getDBDeleteStatement, getDBInsertStatement, getDBLoadStatement, getDBTableName, getDBUpdateStatement, getLogThresholdOperation, getNbDeletes, getNbInserts, getNbUpdates, getPhase, getPhaseInfo
-
Methods inherited from interface fr.dyade.aaa.util.TransactionMBean
backup, dumpObjectList, getCommitCount, getObject, getObjectList, getStartTime, isPersistent, useLoadAll
-
-
-
-
Field Detail
-
JDBC_TRANSACTION_PREFIX
public static final String JDBC_TRANSACTION_PREFIX
- See Also:
- Constant Field Values
-
JDBC_DRIVER_PROP
public static final String JDBC_DRIVER_PROP
This property allows to define the class that implements the JDBC driver, for example "com.mysql.jdbc.Driver". This class needs to be in the classpath of the server.- See Also:
- Constant Field Values
-
JDBC_URL_PROP
public static final String JDBC_URL_PROP
This property allows to define the database url of the form "jdbc:subprotocol://host:port/dbname". If this property is defined, the properties "protocol", "host", "port" and "dbname" below are ignored.- See Also:
- Constant Field Values
-
JDBC_DB_PROTOCOL_PROP
public static final String JDBC_DB_PROTOCOL_PROP
This property allows to define the protocol part of the URL used to establish the connection, for example "jdbc:mysql". It is ignored if the url property is defined.- See Also:
- Constant Field Values
-
JDBC_DB_HOST_PROP
public static final String JDBC_DB_HOST_PROP
This property allows to define the hostname of the URL used to establish the connection. It is ignored if the url property is defined.- See Also:
- Constant Field Values
-
JDBC_DB_PORT_PROP
public static final String JDBC_DB_PORT_PROP
This property allows to define the port of the URL used to establish the connection. It is ignored if the url property is defined.- See Also:
- Constant Field Values
-
JDBC_DB_NAME_PROP
public static final String JDBC_DB_NAME_PROP
This property allows to define the database name of the URL used to establish the connection, by default "JoramDB". It is ignored if the url property is defined.- See Also:
- Constant Field Values
-
DFLT_JDBC_DB_PREFIX
public static final String DFLT_JDBC_DB_PREFIX
- See Also:
- Constant Field Values
-
JDBC_PROPS_FILE_PROP
public static final String JDBC_PROPS_FILE_PROP
This property allows to define the name of a file containing a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included.- See Also:
- Constant Field Values
-
JDBC_DB_USER_PROP
public static final String JDBC_DB_USER_PROP
This property allows to define the name of database user on whose behalf the connection is being made. If this value is already set in properties it is ignored.- See Also:
- Constant Field Values
-
JDBC_DB_PASS_PROP
public static final String JDBC_DB_PASS_PROP
This property allows to define the password of database user on whose behalf the connection is being made. If this value is already set in properties it is ignored.- See Also:
- Constant Field Values
-
JDBC_CONNECT_RETRY_COUNT_PROP
public static final String JDBC_CONNECT_RETRY_COUNT_PROP
This property is used to set the number of reconnection attempts after a failure, by default 5.- See Also:
- Constant Field Values
-
JDBC_CONNECT_RETRY_MIN_DELAY_PROP
public static final String JDBC_CONNECT_RETRY_MIN_DELAY_PROP
This property is used to set the minimum time between two attempts to reconnect after a failure, by default 1.000 (1 seconds).- See Also:
- Constant Field Values
-
JDBC_CONNECT_RETRY_MAX_PERIOD_PROP
public static final String JDBC_CONNECT_RETRY_MAX_PERIOD_PROP
This property is used to set the maximum time trying to reconnect after a failure, by default 60.000 (60 seconds).- See Also:
- Constant Field Values
-
JDBC_DB_INIT_PROP
public static final String JDBC_DB_INIT_PROP
This property allows to define the SQL statement allowing to create the table used by the module, for example: "CREATE TABLE JoramDB (name VARCHAR(256), content LONG VARCHAR FOR BIT DATA, PRIMARY KEY(name))" This property can be set only at first launching.- See Also:
- Constant Field Values
-
JDBC_DB_INSERT_PROP
public static final String JDBC_DB_INSERT_PROP
This property allows to define the SQL statement allowing to insert an entry in the table used by the module, by default: "INSERT INTO <table> VALUES (?, ?)" This property can be set only at first launching.- See Also:
- Constant Field Values
-
JDBC_DB_UPDATE_PROP
public static final String JDBC_DB_UPDATE_PROP
This property allows to define the SQL statement allowing to update an entry in the table used by the module, by default: "UPDATE <table> SET content=? WHERE name=?" This property can be set only at first launching.- See Also:
- Constant Field Values
-
JDBC_DB_LOAD_PROP
public static final String JDBC_DB_LOAD_PROP
This property allows to define the SQL statement allowing to load an entry from the table used by the module, by default: "SELECT content FROM <table> WHERE name=?" This property can be set only at first launching.- See Also:
- Constant Field Values
-
JDBC_DB_DELETE_PROP
public static final String JDBC_DB_DELETE_PROP
This property allows to define the SQL statement allowing to delete an entry in the table used by the module, by default: "DELETE FROM <table> WHERE name=?" This property can be set only at first launching.- See Also:
- Constant Field Values
-
JDBC_DB_CLOSE_PROP
public static final String JDBC_DB_CLOSE_PROP
This property is used to define the SQL statement executed at the end of the module, by default none. This property can be set only at first launching.- See Also:
- Constant Field Values
-
driver
private String driver
-
connurl
private String connurl
-
protocol
private String protocol
-
host
private String host
-
port
private String port
-
user
private String user
-
password
private String password
-
dbname
private String dbname
-
dbinit
private String dbinit
-
path
private String path
-
props
private Properties props
-
-
Method Detail
-
getDBName
public String getDBName()
- Specified by:
getDBNamein interfaceJDBCTransactionMBean
-
getDBInitStatement
public String getDBInitStatement()
- Specified by:
getDBInitStatementin interfaceJDBCTransactionMBean
-
initDB
protected void initDB() throws IOExceptionDescription copied from class:DBTransactionInstantiates the database driver and creates the table if necessary- Specified by:
initDBin classDBTransaction- Throws:
IOException- an error occurs.
-
connectDB
protected void connectDB() throws IOExceptionDescription copied from class:DBTransactionThis method try to reconnect to the database, it is used in case of failure during commit. Be careful, unless a connection pool is used, we need to recreate the prepared statement.- Specified by:
connectDBin classDBTransaction- Throws:
IOException- The reconnection has failed.
-
getDriver
public String getDriver()
- Specified by:
getDriverin interfaceJDBCTransactionMBean
-
getURL
public String getURL()
- Specified by:
getURLin interfaceJDBCTransactionMBean
-
getClientInfo
public Properties getClientInfo()
- Specified by:
getClientInfoin interfaceJDBCTransactionMBean
-
getUser
public String getUser()
- Specified by:
getUserin interfaceJDBCTransactionMBean
-
getPropertiesPath
public String getPropertiesPath()
- Specified by:
getPropertiesPathin interfaceJDBCTransactionMBean
-
dumpProperties
protected void dumpProperties(StringBuilder strbuf)
- Overrides:
dumpPropertiesin classDBTransaction
-
-