Holger's Java API

## com.antelmann.sql
Class SQLServerHelper

    java.lang.Object
      com.antelmann.sql.ConnectionHelper
          com.antelmann.sql.SQLServerHelper

All Implemented Interfaces:
  Wrapped<Connection>

    public class SQLServerHelper

extends ConnectionHelper

provides added functionality for Microsoft SQL Server databases

Since:
  29.04.2013, 15:08:50
Author:
  holger

Constructor Summary
`SQLServerHelper(Connection con)`

Method Summary
`void` `addColumnDefault(String table, String column, String value)`
`void` `addColumnDefault(String table, String column, String constraintName, String value)`
`Number` `adjustForColumn(Number number, int sqltype, int precision)`
`Object` `adjustForColumn(Object value, int sqltype, int precision)`
`Object` `adjustForColumn(Object value, String column, MappingInfo mi)`
`void` `changeOwner(String table, String oldSchema, String newSchema)`
`int` `copyColumnDefaults(String sourceTable, Connection target, String targetTable)`
`boolean` `dropPrimaryKey(String table)`
`Set<String>` `getColumnDefaultConstraintNames(String table)`
`Map<String,Object>` `getColumnDefaults(String table)` returns a map mapping column names to their respective default values.
`ResultSet` `getConstraints(String table)` returns the ResultSet containing the constraints of the given table based on 'exec sp_help'.
`List<String>` `getIndexNames(String table)` somewhat redundant; does the same as `ConnectionHelper.getIndicesForTable(String, boolean)` but in an SQLServer-specific way
`static Logger` `getJDBCLogger()`
`String` `getPrimaryKeyConstraintName(String table)`
`ResultSet` `getSpHelp(String table, int columnIndex, String columnName)` returns the ResultSet based on 'exec sp_help' for the given table where the given columnIndex is named like columnName If no such ResultSet exist, this method returns null.
`boolean` `is2000()`
`ResultSet` `listOpenConnections()`
`void` `lockTable(boolean exclusive, String... tables)` useful for early requiring locks to avoid deadlocks
`void` `removeConstraint(String table, String constraintName)`
`int` `removeDefaults(String table)`

Methods inherited from class com.antelmann.sql.ConnectionHelper

`addIndex, addOrderBy, addPrimaryIndex, addWhereClause, addWhereClause, addWhereClause, addWhereClauseOnSearchPattern, addWhereClauseOnSearchPattern, contains, contains, convertDateRangeToSQL, convertTimestampRangeToSQL, copyIndices, copyPrimaryKey, copyTable, copyTable, copyTo, countDistinctValues, createTableString, delete, deleteRow, deleteRows, dropIndex, escape, escape, executeUpdate, exportAsCSV, exportAsCSV, exportAsCSV, exportAsCSV, extractRow, extractRowItem, extractRows, filterTable, filterTable, filterTable, filterTable, filterTable, filterTable, filterTableForText, filterTableForText, filterTableForText, filterTableScrollable, filterTableUpdateable, findDuplicates, findInTable, getAggregatedFunctionValue, getAggregatedFunctionValue, getAverageValue, getColumnNames, getCommonColumns, getConnection, getCount, getCount, getDateFormat, getDBType, getDistinctValues, getDistinctValues, getDistinctValuesWithCount, getDistinctValuesWithCount, getFetchSize, getFirstRowFor, getForeignKeysModel, getForeingKeys, getFunctionValue, getFunctionValue, getFunctionValue, getFunctionValue, getIndicesForTable, getMaxTextLength, getMaxValue, getMetaDataAsTableModel, getMinValue, getPrimaryKeysForTable, getReservedWords, getResultSet, getResultSet, getRow, getRowItem, getRowItems, getRowItems, getRowItems, getRowItems, getRowItems, getSumValue, getTable, getTableModel, getTableNames, getTypeNameFor, getValue, getViews, importTableModel, insert, insertRow, insertRow, insertRow, insertRowWithGeneratedKeys, insertTableModel, isCharType, isDateType, isMSAccess, isMySQL, isNumberType, isSelect, isSQLServer, iterate, javaToSql, loadAsMap, loadTable, loadTable, mapColumnNamesToDisplayNames, mapColumnNamesToSize, mapColumnNamesToSize, mapColumnNamesToSize, mapColumnNamesToSQLTypes, mapColumnNamesToSQLTypes, mapColumnNamesToTypeString, mapColumnNamesToTypeString, needsSelect, processColumn, queryDuplicates, replace, searchDatabaseFor, searchDuplicates, setDateFormat, setDoNotEscapeNames, setEscapeChars, setFetchSize, sqlToJava, transferTable, trimToLastDot, unwrap, update, update, update, updateRows, updateRows, updateRows, updateTable`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SQLServerHelper

    public SQLServerHelper(Connection con)

Method Detail

### is2000

    public boolean is2000()
                   throws SQLException

  Throws:
    `SQLException`

### lockTable

    public void lockTable(boolean exclusive,
                          String... tables)
                   throws SQLException

  Description copied from class: `ConnectionHelper`
  useful for early requiring locks to avoid deadlocks

  Overrides:
    `lockTable` in class `ConnectionHelper`
  Throws:
    `SQLException`

### addColumnDefault

    public void addColumnDefault(String table,
                                 String column,
                                 String value)
                          throws SQLException

  Throws:
    `SQLException`

### addColumnDefault

    public void addColumnDefault(String table,
                                 String column,
                                 String constraintName,
                                 String value)
                          throws SQLException

  Throws:
    `SQLException`

### removeConstraint

    public void removeConstraint(String table,
                                 String constraintName)
                          throws SQLException

  Throws:
    `SQLException`

### getSpHelp

    public ResultSet getSpHelp(String table,
                               int columnIndex,
                               String columnName)
                        throws SQLException

  returns the ResultSet based on 'exec sp_help' for the given table where the given columnIndex is named like columnName If no such ResultSet exist, this method returns null.

  Throws:
    `SQLException`

### listOpenConnections

    public ResultSet listOpenConnections()
                                  throws SQLException

  Throws:
    `SQLException`

### getConstraints

    public ResultSet getConstraints(String table)
                             throws SQLException

  returns the ResultSet containing the constraints of the given table based on 'exec sp_help'. If no constraints exist, this method returns null.

  Throws:
    `SQLException`

### copyColumnDefaults

    public int copyColumnDefaults(String sourceTable,
                                  Connection target,
                                  String targetTable)
                           throws SQLException

  Throws:
    `SQLException`

### removeDefaults

    public int removeDefaults(String table)
                       throws SQLException

  Throws:
    `SQLException`

### getColumnDefaultConstraintNames

    public Set<String> getColumnDefaultConstraintNames(String table)
                                                throws SQLException

  Throws:
    `SQLException`

### getColumnDefaults

    public Map<String,Object> getColumnDefaults(String table)
                                         throws SQLException

  returns a map mapping column names to their respective default values.

  Throws:
    `SQLException`

### dropPrimaryKey

    public boolean dropPrimaryKey(String table)
                           throws SQLException

  Throws:
    `SQLException`

### getPrimaryKeyConstraintName

    public String getPrimaryKeyConstraintName(String table)
                                       throws SQLException

  Throws:
    `SQLException`

### getIndexNames

    public List<String> getIndexNames(String table)
                               throws SQLException

  somewhat redundant; does the same as `ConnectionHelper.getIndicesForTable(String, boolean)` but in an SQLServer-specific way

  Throws:
    `SQLException`
  See Also:
    `ConnectionHelper.getIndicesForTable(String, boolean)`

### changeOwner

    public void changeOwner(String table,
                            String oldSchema,
                            String newSchema)
                     throws SQLException,
                            IllegalArgumentException

  Throws:
    `SQLException`
    `IllegalArgumentException`

### adjustForColumn

    public Object adjustForColumn(Object value,
                                  String column,
                                  MappingInfo mi)
                           throws SQLException,
                                  IllegalArgumentException

  Throws:
    `SQLException`
    `IllegalArgumentException`

### adjustForColumn

    public Object adjustForColumn(Object value,
                                  int sqltype,
                                  int precision)
                           throws SQLException,
                                  IllegalArgumentException

  Throws:
    `SQLException`
    `IllegalArgumentException`

### adjustForColumn

    public Number adjustForColumn(Number number,
                                  int sqltype,
                                  int precision)
                           throws SQLException,
                                  IllegalArgumentException

  Throws:
    `SQLException`
    `IllegalArgumentException`

### getJDBCLogger

    public static Logger getJDBCLogger()

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads