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
ConstructorsModifierConstructorDescriptionprotectedcreates a new PostgresqlDatabaseAdapter for test purposes, without connection to the DBPostgresDatabaseAdapter(Properties connInfo)creates a new PostgresqlDatabaseAdapter -
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 existsintgetLastInsertId(String table, String idcolumn)gets the id of the last insert.protected StringrewriteSql(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: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.
-
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
-
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:
getLastInsertIdin interfaceDatabaseAdapter- Overrides:
getLastInsertIdin 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:
rewriteSqlin classAbstractDatabaseAdapter- Parameters:
sql- original SQL statement- Returns:
- modified SQL statement
- Throws:
SQLException- in case of a database error
-