|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.mavenhist.persistency.AbstractDatabasePersistency
public abstract class AbstractDatabasePersistency
Supports an easy implementation of a DB-persistency Layer. It supports connection handling and execution of queries with exception handling.
Constructor Summary | |
---|---|
AbstractDatabasePersistency(String dbUser,
String dbPassword,
String dbURL)
Creates a new db persistency object. |
Method Summary | |
---|---|
protected void |
closeConnection(Connection conn)
Closes a db connection opened by getConnection() . |
protected void |
commit(Connection conn)
Commits on connection and rethrows eventually generated Exceptions . |
protected boolean |
executeCreateStatement(Connection conn,
String sql)
Executes a create operation on the database. |
boolean |
executeCreateStatement(String sql)
Executes a create operation on the database. |
protected Object |
executeQueryStatement(Connection conn,
String sql,
Object[] args,
IResultSetProcessor resultSetProcessor)
Executes a query operation on the database. |
Object |
executeQueryStatement(String sql,
Object[] args,
IResultSetProcessor resultSetProcessor)
Executes a query operation on the database. |
protected int |
executeUpdateStatement(Connection conn,
String sql,
Object[] args)
Executes an update statement (queries won't work, only insert/update calls allowed). |
int |
executeUpdateStatement(String sql,
Object[] args)
Executes an update statement (queries wont work, only insert/update calls allowed). |
protected Connection |
getConnection()
Gets a db connection, must be released by calling closeConnection(Connection) . |
abstract String |
getDbDriverClass()
Gets dbDriverName. |
String |
getPassword()
Gets dbPassword. |
String |
getURL()
Gets dbURL. |
String |
getUser()
Gets dbUser. |
void |
setPassword(String dbPassword)
Sets dbPassword. |
void |
setURL(String dbURL)
Sets dbURL. |
void |
setUser(String dbUser)
Sets dbUser. |
void |
storeMetric(Metric metric)
Stores the metric by calling the method storeMetric . |
protected abstract void |
storeMetric(Metric metric,
Connection conn)
Hook implementation to store a metric value in a customized matter. |
void |
storeMetrics(Metric[] metrics)
Stores the metrics by calling the method storeMetric . |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.mavenhist.persistency.IPersistency |
---|
initializeMetricsDataBase |
Constructor Detail |
---|
public AbstractDatabasePersistency(String dbUser, String dbPassword, String dbURL)
dbUser
- the username for the db.dbPassword
- the password for the db.dbURL
- the server URL of the db.Method Detail |
---|
protected Connection getConnection() throws PersistencyException
closeConnection(Connection)
.
PersistencyException
- in case of errorprotected void commit(Connection conn) throws PersistencyException
Exceptions
.
conn
- to commit on.
PersistencyException
- thrown when commit fails.protected void closeConnection(Connection conn) throws PersistencyException
getConnection()
.
conn
- to be closed.
PersistencyException
- in case of errorpublic Object executeQueryStatement(String sql, Object[] args, IResultSetProcessor resultSetProcessor) throws PersistencyException
sql
- to be queried.args
- to be filled in for all '?'resultSetProcessor
- to process the result set.
PersistencyException
- in case of error.protected Object executeQueryStatement(Connection conn, String sql, Object[] args, IResultSetProcessor resultSetProcessor) throws PersistencyException
conn
- to be used.sql
- to be queried.args
- to be filled in for all '?'resultSetProcessor
- to process the result set.
PersistencyException
- in case of error.public boolean executeCreateStatement(String sql) throws PersistencyException
sql
- to be queried.
ResultSet
object; false if the first result is
an update count or there is no result.
PersistencyException
- in case of error.protected boolean executeCreateStatement(Connection conn, String sql) throws PersistencyException
conn
- to be used.sql
- to be queried.
ResultSet
object; false if the first result is
an update count or there is no result
PersistencyException
- in case of error.public int executeUpdateStatement(String sql, Object[] args) throws PersistencyException
sql
- to be executedargs
- to be filled in for all '?'
PersistencyException
- in case of errorprotected int executeUpdateStatement(Connection conn, String sql, Object[] args) throws PersistencyException
conn
- connection to be usedsql
- to be executedargs
- to be filled in for all '?'
PersistencyException
- in case of errorpublic void storeMetrics(Metric[] metrics) throws PersistencyException
storeMetric
.
Stores a collection of metrics to a persistable form.
storeMetrics
in interface IPersistency
metrics
- to store
PersistencyException
- in case of errorpublic void storeMetric(Metric metric) throws PersistencyException
storeMetric
.
metric
- metric to store in the DB.
PersistencyException
- if storing fails.protected abstract void storeMetric(Metric metric, Connection conn) throws PersistencyException
metric
- to store in the DB.conn
- to access the database and store the metric.
PersistencyException
- thrown if something fails.public String getPassword()
getPassword
in interface IConfigurablePersistency
public void setPassword(String dbPassword)
setPassword
in interface IConfigurablePersistency
dbPassword
- dbPassword to setpublic String getURL()
getURL
in interface IConfigurablePersistency
public void setURL(String dbURL)
setURL
in interface IConfigurablePersistency
dbURL
- dbURL to setpublic String getUser()
getUser
in interface IConfigurablePersistency
public void setUser(String dbUser)
setUser
in interface IConfigurablePersistency
dbUser
- dbUser to setpublic abstract String getDbDriverClass()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |