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
ModifierConstructorDescriptionprotected
creates a new H2Adapter for test purposes, without connection to the DBH2DatabaseAdapter(Properties connInfo)
creates a new H2Adapter -
Method Summary
Modifier and TypeMethodDescriptionprotected Connection
createConnection(Properties connInfo)
This method creates the real connection to database.boolean
doesColumnExist(String table, String column)
checks whether the specified column existsboolean
doesTableExist(String table)
checks whether the specified table existsint
getColumnLength(String table, String column)
Gets the length of the specified columnprotected String
rewriteSql(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:AbstractDatabaseAdapter
This method creates the real connection to database.- Overrides:
createConnection
in 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:
rewriteSql
in classAbstractDatabaseAdapter
- Parameters:
sql
- original SQL statement- Returns:
- modified SQL statement
-
doesTableExist
Description copied from interface:DatabaseAdapter
checks whether the specified table exists- Specified by:
doesTableExist
in interfaceDatabaseAdapter
- Overrides:
doesTableExist
in 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:DatabaseAdapter
checks whether the specified column exists- Specified by:
doesColumnExist
in interfaceDatabaseAdapter
- Overrides:
doesColumnExist
in 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:DatabaseAdapter
Gets the length of the specified column- Specified by:
getColumnLength
in interfaceDatabaseAdapter
- Overrides:
getColumnLength
in 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
-