|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.janrufmonitor.repository.db.AbstractDatabaseHandler
public abstract class AbstractDatabaseHandler
This abstract class can be used as base class for a database related managers. It contains methods for database creation and prepared statements for manager handling.
| Field Summary | |
|---|---|
protected int |
commit_count
|
protected Connection |
m_con
|
protected Logger |
m_logger
|
protected Map |
m_preparedStatements
|
| Constructor Summary | |
|---|---|
AbstractDatabaseHandler(String driver,
String connection,
String user,
String password,
boolean initialize)
Constructor dor a data handler calling the underlaying database |
|
| Method Summary | |
|---|---|
protected abstract void |
addPreparedStatements()
Add all required prepares statements to the m_preparedStatements map. |
void |
commit()
Commits the changed data to the database. |
void |
connect()
Connects to the database specified in the constructor. |
protected void |
createAttributes(PreparedStatement ps,
String uuid,
IAttributeMap m)
|
protected abstract void |
createTables()
Creates the database table. |
protected void |
deleteAttributes(PreparedStatement ps,
String uuid)
|
void |
disconnect()
Disconnects the current db and shuts it down. |
protected abstract IRuntime |
getRuntime()
|
protected PreparedStatement |
getStatement(String id)
|
boolean |
isConnected()
Checks wether a connection is established or not. |
protected boolean |
isInitializing()
Must return true, if the database tables should be created. |
boolean |
isKeepAlive()
|
void |
rollback()
Rolls back the db changed since the last commit. |
void |
setCommitCount(int c)
|
protected void |
setInitializing(boolean init)
Sets the initinal attribute of the database. |
void |
setKeepAlive(boolean keep)
|
protected void |
updateAttributes(PreparedStatement ps,
String uuid,
IAttributeMap m)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Connection m_con
protected Map m_preparedStatements
protected Logger m_logger
protected int commit_count
| Constructor Detail |
|---|
public AbstractDatabaseHandler(String driver,
String connection,
String user,
String password,
boolean initialize)
driver - JDBC driver stringconnection - connection Stringuser - user, if requiredpassword - password, if user was setinitialize - indicates wether the db tables must be created or not.| Method Detail |
|---|
protected abstract IRuntime getRuntime()
protected abstract void createTables()
throws SQLException
SQLException
protected abstract void addPreparedStatements()
throws SQLException
SQLException
public boolean isConnected()
throws SQLException
isConnected in interface IDatabaseHandlerSQLException
public void connect()
throws SQLException,
ClassNotFoundException
connect in interface IDatabaseHandlerSQLException - is thrown, if any exception on the db level occurs.
ClassNotFoundException - is thrown, if the db driver could not be loaded.protected boolean isInitializing()
protected void setInitializing(boolean init)
protected PreparedStatement getStatement(String id)
protected void createAttributes(PreparedStatement ps,
String uuid,
IAttributeMap m)
throws SQLException
SQLException
protected void deleteAttributes(PreparedStatement ps,
String uuid)
throws SQLException
SQLException
protected void updateAttributes(PreparedStatement ps,
String uuid,
IAttributeMap m)
throws SQLException
SQLException
public void commit()
throws SQLException
commit in interface IDatabaseHandlerSQLException
public void rollback()
throws SQLException
rollback in interface IDatabaseHandlerSQLException
public void disconnect()
throws SQLException
disconnect in interface IDatabaseHandlerSQLExceptionpublic void setCommitCount(int c)
setCommitCount in interface IDatabaseHandlerpublic boolean isKeepAlive()
isKeepAlive in interface IDatabaseHandlerpublic void setKeepAlive(boolean keep)
setKeepAlive in interface IDatabaseHandler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||