Package edu.ucsb.nceas.dbadapter
Class PostgresqlAdapter
java.lang.Object
edu.ucsb.nceas.dbadapter.AbstractDatabase
edu.ucsb.nceas.dbadapter.PostgresqlAdapter
The PostgreSQL db adapter implementation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionThe PostgreSQL function name that gets the current date and time from the database serverThe PostgreSQL function name that is used to return non-NULL valuegetLeftJoinQuery
(String selectFields, String tableA, String tableB, String joinCriteria, String nonJoinCriteria) PostgreSQL's syntax for doing a left join Add 'a.' in front of the fields for first table and 'b.' in front of the fields for the second tablegetPagedQuery
(String queryWithOrderBy, Integer start, Integer count) for generating a query for pagingReturn a hard code string to get xml_document list in timed replcationPostgreSQL's string delimiter character: single quote (')long
getUniqueID
(Connection conn, String tableName) The PostgreSQL unique ID /sequence generator The name of the sequence used to generate the unique id is made from the name of the table that uses the id by appending "_id_seq" to it.Methods inherited from class edu.ucsb.nceas.dbadapter.AbstractDatabase
createObject, main, toDate
-
Constructor Details
-
PostgresqlAdapter
public PostgresqlAdapter()
-
-
Method Details
-
getUniqueID
The PostgreSQL unique ID /sequence generator The name of the sequence used to generate the unique id is made from the name of the table that uses the id by appending "_id_seq" to it. When record is inserted in the table and insert trigger gets a nextval from that sequence, select currval of that sequence can return the generated key in the same db connection.- Specified by:
getUniqueID
in classAbstractDatabase
- Parameters:
conn
- db connection in which the unique id was generatedtableName
- the name of table which unique id was generate- Returns:
- return the generated unique id as a long type
- Throws:
SQLException
- any SQLException that can be thrown during the db operation
-
getDateTimeFunction
The PostgreSQL function name that gets the current date and time from the database server- Specified by:
getDateTimeFunction
in classAbstractDatabase
- Returns:
- return the current date and time function name: "now()"
-
getIsNULLFunction
The PostgreSQL function name that is used to return non-NULL value- Specified by:
getIsNULLFunction
in classAbstractDatabase
- Returns:
- return the non-NULL function name: "coalesce"
-
getStringDelimiter
PostgreSQL's string delimiter character: single quote (')- Specified by:
getStringDelimiter
in classAbstractDatabase
- Returns:
- return the string delimiter: single quote (')
-
getLeftJoinQuery
public String getLeftJoinQuery(String selectFields, String tableA, String tableB, String joinCriteria, String nonJoinCriteria) PostgreSQL's syntax for doing a left join Add 'a.' in front of the fields for first table and 'b.' in front of the fields for the second table- Specified by:
getLeftJoinQuery
in classAbstractDatabase
- Parameters:
selectFields
- fields that you want to be selectedtableA
- first table in the jointableB
- second table in the joinjoinCriteria
- the criteria based on which the join will be madenonJoinCriteria
- all other criterias- Returns:
- return the string for teh select query
-
getReplicationDocumentListSQL
Return a hard code string to get xml_document list in timed replcation- Specified by:
getReplicationDocumentListSQL
in classAbstractDatabase
- Returns:
-
getPagedQuery
Description copied from class:AbstractDatabase
for generating a query for paging- Specified by:
getPagedQuery
in classAbstractDatabase
- Parameters:
queryWithOrderBy
- - the complete query with SELECT, FROM, WHERE and ORDER BY clausesstart
- the row number to start fromcount
- the number of records from start to return- Returns:
- query specific to the RDBMS in use
-