edu.ucsb.nceas.dbadapter

## Class SqlserverAdapter

- java.lang.Object
- - edu.ucsb.nceas.dbadapter.AbstractDatabase
  - - edu.ucsb.nceas.dbadapter.SqlserverAdapter

-     public class SqlserverAdapter
      extends AbstractDatabase

  The MS SQL Server db adapter implementation.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SqlserverAdapter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getDateTimeFunction()` The SQL Server's function name that gets the current date and time from the database server: "getdate()"
    `java.lang.String` | `getIsNULLFunction()` The SQL Server's function name that is used to return non-NULL value
    `java.lang.String` | `getLeftJoinQuery(java.lang.String selectFields, java.lang.String tableA, java.lang.String tableB, java.lang.String joinCriteria, java.lang.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
    `java.lang.String` | `getPagedQuery(java.lang.String queryFieldsWithOrderBy, java.lang.Integer start, java.lang.Integer count)` for generating a query for paging
    `java.lang.String` | `getReplicationDocumentListSQL()` Return a hard code string to get xml_document list in timed replcation
    `java.lang.String` | `getStringDelimiter()` The SQL Server's string delimiter character: single quote (')
    `long` | `getUniqueID(java.sql.Connection conn, java.lang.String tableName)` The SQL Server unique ID generator through use of IDENTITY key The IDENTITY key is a column in the table.
    `java.lang.String` | `toDate(java.lang.String dateString, java.lang.String format)` MSSQL doesn't support the to_date function, so we transfer text directly.

    - ### Methods inherited from class edu.ucsb.nceas.dbadapter.AbstractDatabase

      `createObject, main`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SqlserverAdapter

          public SqlserverAdapter()

  - ### Method Detail

    - #### getUniqueID

          public long getUniqueID(java.sql.Connection conn,
                                  java.lang.String tableName)
                           throws java.sql.SQLException

      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 class `AbstractDatabase`
      Parameters:
        `conn` - db connection in which to generate the unique id
        `tableName` - the name of table which unique id to generate
      Returns:
        return the generated unique id as a long type
      Throws:
        `java.sql.SQLException` -
        any SQLException that can be thrown during the db operation

    - #### getDateTimeFunction

          public java.lang.String getDateTimeFunction()

      The SQL Server's function name that gets the current date and time from the database server: "getdate()"
      Specified by:
        `getDateTimeFunction` in class `AbstractDatabase`
      Returns:
        return the current date and time function name: "getdate()"

    - #### getIsNULLFunction

          public java.lang.String getIsNULLFunction()

      The SQL Server's function name that is used to return non-NULL value
      Specified by:
        `getIsNULLFunction` in class `AbstractDatabase`
      Returns:
        return the non-NULL function name: "isnull"

    - #### getStringDelimiter

          public java.lang.String getStringDelimiter()

      The SQL Server's string delimiter character: single quote (')
      Specified by:
        `getStringDelimiter` in class `AbstractDatabase`
      Returns:
        return the string delimiter: single quote (')

    - #### toDate

          public java.lang.String toDate(java.lang.String dateString,
                                         java.lang.String format)

      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 class `AbstractDatabase`

    - #### getLeftJoinQuery

          public java.lang.String getLeftJoinQuery(java.lang.String selectFields,
                                                   java.lang.String tableA,
                                                   java.lang.String tableB,
                                                   java.lang.String joinCriteria,
                                                   java.lang.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 class `AbstractDatabase`
      Parameters:
        `selectFields` - fields that you want to be selected
        `tableA` - first table in the join
        `tableB` - second table in the join
        `joinCriteria` - the criteria based on which the join will be made
        `nonJoinCriteria` - all other criterias
      Returns:
        return the string for teh select query

    - #### getReplicationDocumentListSQL

          public java.lang.String getReplicationDocumentListSQL()

      Return a hard code string to get xml_document list in timed replcation
      Specified by:
        `getReplicationDocumentListSQL` in class `AbstractDatabase`
      Returns:

    - #### getPagedQuery

          public java.lang.String getPagedQuery(java.lang.String queryFieldsWithOrderBy,
                                                java.lang.Integer start,
                                                java.lang.Integer count)

      Description copied from class: `AbstractDatabase`
      for generating a query for paging
      Specified by:
        `getPagedQuery` in class `AbstractDatabase`
      Parameters:
        `queryFieldsWithOrderBy` - - the complete query with SELECT, FROM, WHERE and ORDER BY clauses
        `start` - the row number to start from
        `count` - the number of records from start to return
      Returns:
        query specific to the RDBMS in use

Copyright © 2020 Regents of the University of California. All Rights Reserved.