Class SqlserverAdapter


public class SqlserverAdapter extends AbstractDatabase
The MS SQL Server db adapter implementation.
  • Constructor Details

    • SqlserverAdapter

      public SqlserverAdapter()
  • Method Details

    • getUniqueID

      public long getUniqueID(Connection conn, String tableName) throws 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
      conn - db connection in which to generate the unique id
      tableName - the name of table which unique id to generate
      return the generated unique id as a long type
      SQLException -
      any SQLException that can be thrown during the db operation
    • getDateTimeFunction

      public 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
      return the current date and time function name: "getdate()"
    • getIsNULLFunction

      public String getIsNULLFunction()
      The SQL Server's function name that is used to return non-NULL value
      Specified by:
      getIsNULLFunction in class AbstractDatabase
      return the non-NULL function name: "isnull"
    • getStringDelimiter

      public String getStringDelimiter()
      The SQL Server's string delimiter character: single quote (')
      Specified by:
      getStringDelimiter in class AbstractDatabase
      return the string delimiter: single quote (')
    • toDate

      public String toDate(String dateString, String format)
      MSSQL doesn't support the to_date function, so we transfer text directly. This method will overwrite the method in AbstarctDatabase class
      toDate in class AbstractDatabase
    • 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 class AbstractDatabase
      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
      return the string for teh select query
    • getReplicationDocumentListSQL

      public String getReplicationDocumentListSQL()
      Return a hard code string to get xml_document list in timed replcation
      Specified by:
      getReplicationDocumentListSQL in class AbstractDatabase
    • getPagedQuery

      public String getPagedQuery(String queryFieldsWithOrderBy, Integer start, Integer count)
      Description copied from class: AbstractDatabase
      for generating a query for paging
      Specified by:
      getPagedQuery in class AbstractDatabase
      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
      query specific to the RDBMS in use