Class SDriverMSSQL


  • public class SDriverMSSQL
    extends SDriver
    This contains MS SQL Server specific code.

    CHAR, VARCHAR max 8,000. TEXT 2^31. NVARCHAR/NCHAR UTF16, max size 4,000.

    • Constructor Detail

      • SDriverMSSQL

        public SDriverMSSQL()
    • Method Detail

      • driverName

        protected java.lang.String driverName()
        Description copied from class: SDriver
        The driver name to be compared to getMetaData().getDriverName()
        Overrides:
        driverName in class SDriver
      • columnTypeSQL

        protected java.lang.String columnTypeSQL​(SFieldScalar field,
                                                 java.lang.String defalt)
        Apparently need DATETIME instead of TIMESTAMP
        Overrides:
        columnTypeSQL in class SDriver
      • forUpdateSQL

        protected java.lang.String forUpdateSQL​(boolean forUpdate)
        Description copied from class: SDriver
        Returns update clause, may not be valid in certain lock modes etc. Right at the end of the query.

        Oracle, Postgresql, and new in MS SQL 2005 support data versioning or snapshots. This means that repeatable read is achieved by caching the previous value read instead of using read locks. This approach makes it critical to add FOR UPDATE where appropriate or there is effectively no locking.

        Indeed, in Oracle, you are guaranteed that several SELECTS will return the same value, but a subsequent SELECT FOR UPDATE in the same transaction may return a different value.

        Overrides:
        forUpdateSQL in class SDriver
      • postFromSQL

        protected java.lang.String postFromSQL​(boolean forUpdate)
        It is unclear how MS SQL 2005 does snapshot locking -- very complex, needs experimentation. http://msdn.microsoft.com/en-us/library/ms345124.aspx

        Need for XLOCK is unclear. However, Jorge says that it is unnecessary and makes SimpleORM fail, but it works for me.

        Overrides:
        postFromSQL in class SDriver
        See Also:
        for discussion.
      • setXLockEnabled

        public void setXLockEnabled​(boolean xlock)
        Enables WITH (XLOCK) for updatable queries. Should reduce deadlocks but apparantly can cause bugs. (Not supported in SQL 7? Something about HOLDLOCK?)
      • getXLockEnabled

        public boolean getXLockEnabled()
      • alterTableAddColumnSQL

        public java.lang.String alterTableAddColumnSQL​(SFieldScalar field)
        Description copied from class: SDriver
        These alow you to create a new SFieldMeta object at runtime and then update the table to include it. Eg. for end user customizations. ## Ideally this could be further automated so that the SRecordMeta and JDBC meta data for a table could be compared and the table automatically altered.
        Overrides:
        alterTableAddColumnSQL in class SDriver