Package edu.ucsb.nceas.dbadapter
Class SqlserverAdapter
java.lang.Object
edu.ucsb.nceas.dbadapter.AbstractDatabase
edu.ucsb.nceas.dbadapter.SqlserverAdapter
The MS SQL Server db adapter implementation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionThe SQL Server's function name that gets the current date and time from the database server: "getdate()"The SQL Server's function name that is used to return non-NULL valuegetLeftJoinQuery
(String selectFields, String tableA, String tableB, String joinCriteria, String nonJoinCriteria) MSSQL'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 queryFieldsWithOrderBy, Integer start, Integer count) for generating a query for pagingReturn a hard code string to get xml_document list in timed replcationThe SQL Server's string delimiter character: single quote (')long
getUniqueID
(Connection conn, String tableName) The SQL Server unique ID generator through use of IDENTITY key The IDENTITY key is a column in the table.MSSQL doesn't support the to_date function, so we transfer text directly.Methods inherited from class edu.ucsb.nceas.dbadapter.AbstractDatabase
createObject, main
-
Constructor Details
-
SqlserverAdapter
public SqlserverAdapter()
-
-
Method Details
-
getUniqueID
The SQL Server unique ID generator through use of IDENTITY key The IDENTITY key is a column in the table. When record is inserted in the table, SELECT @@IDENTITY can return the key generated in that IDENTITY column in the same db connection. This is the only way to get unique id: let the SQL Server assign a value in IDENTITY column and get it afterwards for use in the application.- Specified by:
getUniqueID
in classAbstractDatabase
- Parameters:
conn
- db connection in which to generate the unique idtableName
- the name of table which unique id to 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 SQL Server's function name that gets the current date and time from the database server: "getdate()"- Specified by:
getDateTimeFunction
in classAbstractDatabase
- Returns:
- return the current date and time function name: "getdate()"
-
getIsNULLFunction
The SQL Server's function name that is used to return non-NULL value- Specified by:
getIsNULLFunction
in classAbstractDatabase
- Returns:
- return the non-NULL function name: "isnull"
-
getStringDelimiter
The SQL Server's string delimiter character: single quote (')- Specified by:
getStringDelimiter
in classAbstractDatabase
- Returns:
- return the string delimiter: single quote (')
-
toDate
MSSQL doesn't support the to_date function, so we transfer text directly. This method will overwrite the method in AbstarctDatabase class- Overrides:
toDate
in classAbstractDatabase
-
getLeftJoinQuery
public String getLeftJoinQuery(String selectFields, String tableA, String tableB, String joinCriteria, String nonJoinCriteria) MSSQL'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:
queryFieldsWithOrderBy
- - 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
-