Package marauroa.server.db.adapter
Class H2DatabaseAdapter
java.lang.Object
marauroa.server.db.adapter.AbstractDatabaseAdapter
marauroa.server.db.adapter.H2DatabaseAdapter
- All Implemented Interfaces:
DatabaseAdapter
abstracts from H2 specifications
- Author:
- hendrik
-
Field Summary
Fields inherited from class marauroa.server.db.adapter.AbstractDatabaseAdapter
connection, resultSets, statements -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedcreates a new H2Adapter for test purposes, without connection to the DBH2DatabaseAdapter(Properties connInfo)creates a new H2Adapter -
Method Summary
Modifier and TypeMethodDescriptionprotected ConnectioncreateConnection(Properties connInfo)This method creates the real connection to database.booleandoesColumnExist(String table, String column)checks whether the specified column existsbooleandoesTableExist(String table)checks whether the specified table existsintgetColumnLength(String table, String column)Gets the length of the specified columnprotected StringrewriteSql(String sql)rewrites ALTER TABLE statements to remove the "COLUMNS (" partMethods inherited from class marauroa.server.db.adapter.AbstractDatabaseAdapter
close, commit, execute, execute, executeBatch, getLastInsertId, isConnectionError, prepareStatement, query, querySingleCellInt, rollback, verifyConnection
-
Constructor Details
-
H2DatabaseAdapter
creates a new H2Adapter- Parameters:
connInfo- parameters specifying the connection- Throws:
DatabaseConnectionException- if the connection cannot be established.
-
H2DatabaseAdapter
creates a new H2Adapter for test purposes, without connection to the DB- Throws:
DatabaseConnectionException- if the connection cannot be established.
-
-
Method Details
-
createConnection
protected Connection createConnection(Properties connInfo) throws SQLException, DatabaseConnectionExceptionDescription copied from class:AbstractDatabaseAdapterThis method creates the real connection to database.- Overrides:
createConnectionin classAbstractDatabaseAdapter- Parameters:
connInfo- connection information like url, username and password- Returns:
- a connection to the database
- Throws:
SQLException- if the connection cannot be established.DatabaseConnectionException- if the connection cannot be established.
-
rewriteSql
rewrites ALTER TABLE statements to remove the "COLUMNS (" part- Overrides:
rewriteSqlin classAbstractDatabaseAdapter- Parameters:
sql- original SQL statement- Returns:
- modified SQL statement
-
doesTableExist
Description copied from interface:DatabaseAdapterchecks whether the specified table exists- Specified by:
doesTableExistin interfaceDatabaseAdapter- Overrides:
doesTableExistin classAbstractDatabaseAdapter- Parameters:
table- name of table- Returns:
- true, if the table exists, false otherwise
- Throws:
SQLException- in case of an database error
-
doesColumnExist
Description copied from interface:DatabaseAdapterchecks whether the specified column exists- Specified by:
doesColumnExistin interfaceDatabaseAdapter- Overrides:
doesColumnExistin classAbstractDatabaseAdapter- Parameters:
table- name of tablecolumn- name of column- Returns:
- true, if the column exists, false otherwise
- Throws:
SQLException- in case of an database error
-
getColumnLength
Description copied from interface:DatabaseAdapterGets the length of the specified column- Specified by:
getColumnLengthin interfaceDatabaseAdapter- Overrides:
getColumnLengthin classAbstractDatabaseAdapter- Parameters:
table- name of tablecolumn- name of column- Returns:
- the length of the column or -1 if no column with the given name in the given table exists
- Throws:
SQLException- in case of an database error
-