Package marauroa.server.db.adapter
Class PostgresDatabaseAdapter
java.lang.Object
marauroa.server.db.adapter.AbstractDatabaseAdapter
marauroa.server.db.adapter.PostgresDatabaseAdapter
- All Implemented Interfaces:
DatabaseAdapter
abstracts from PostgreSQL specifications
- Author:
- hendrik
-
Field Summary
Fields inherited from class marauroa.server.db.adapter.AbstractDatabaseAdapter
connection, resultSets, statements
-
Constructor Summary
ModifierConstructorDescriptionprotected
creates a new PostgresqlDatabaseAdapter for test purposes, without connection to the DBPostgresDatabaseAdapter(Properties connInfo)
creates a new PostgresqlDatabaseAdapter -
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 existsint
getLastInsertId(String table, String idcolumn)
gets the id of the last insert.protected String
rewriteSql(String sql)
rewrites CREATE TABLE statements to add TYPE=InnoDBMethods inherited from class marauroa.server.db.adapter.AbstractDatabaseAdapter
close, commit, doesTableExist, execute, execute, executeBatch, getColumnLength, isConnectionError, prepareStatement, query, querySingleCellInt, rollback, verifyConnection
-
Constructor Details
-
PostgresDatabaseAdapter
creates a new PostgresqlDatabaseAdapter- Parameters:
connInfo
- parameters specifying the connection- Throws:
DatabaseConnectionException
- if the connection cannot be established.
-
PostgresDatabaseAdapter
creates a new PostgresqlDatabaseAdapter 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.
-
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
-
getLastInsertId
gets the id of the last insert. Note: The table and idcolumn parameters must match the last insert statement. This is because on some database systems a SELECT IDENTITY is performed and on other database systems a SELECT curval(table_idcolumn_seq).- Specified by:
getLastInsertId
in interfaceDatabaseAdapter
- Overrides:
getLastInsertId
in classAbstractDatabaseAdapter
- Parameters:
table
- name of table on which the last insert was doneidcolumn
- name autoincrement serial column of that table- Returns:
- generated id
- Throws:
SQLException
- in case of an database error
-
rewriteSql
rewrites CREATE TABLE statements to add TYPE=InnoDB- Overrides:
rewriteSql
in classAbstractDatabaseAdapter
- Parameters:
sql
- original SQL statement- Returns:
- modified SQL statement
- Throws:
SQLException
- in case of a database error
-