public class DBDatabaseDriverMSSQL extends DBDatabaseDriver
Modifier and Type | Class and Description |
---|---|
static class |
DBDatabaseDriverMSSQL.DBCommandMSSQL
Defines the Microsoft SQL-Server command type.
|
DBDatabaseDriver.DBSeqTable, DBDatabaseDriver.DBSetGenKeys
Modifier and Type | Field and Description |
---|---|
protected DBDDLGenerator<?> |
ddlGenerator |
protected static String[] |
MSSQL_SQL_KEYWORDS |
ddlColumnDefaults, GENERAL_SQL_KEYWORDS, ILLEGAL_NAME_CHARS, reservedSQLKeywords, SQL_BOOLEAN_FALSE, SQL_BOOLEAN_TRUE, SQL_CONCAT_EXPR, SQL_CURRENT_DATE, SQL_CURRENT_TIMESTAMP, SQL_DATABASE_LINK, SQL_DATE_PATTERN, SQL_DATE_TEMPLATE, SQL_DATETIME_PATTERN, SQL_DATETIME_TEMPLATE, SQL_FUNC_ABS, SQL_FUNC_AVG, SQL_FUNC_CEILING, SQL_FUNC_COALESCE, SQL_FUNC_DAY, SQL_FUNC_DECODE, SQL_FUNC_DECODE_ELSE, SQL_FUNC_DECODE_PART, SQL_FUNC_DECODE_SEP, SQL_FUNC_ESCAPE, SQL_FUNC_FLOOR, SQL_FUNC_FORMAT, SQL_FUNC_LENGTH, SQL_FUNC_LOWER, SQL_FUNC_LTRIM, SQL_FUNC_MAX, SQL_FUNC_MIN, SQL_FUNC_MODULO, SQL_FUNC_MONTH, SQL_FUNC_REPLACE, SQL_FUNC_REVERSE, SQL_FUNC_ROUND, SQL_FUNC_RTRIM, SQL_FUNC_STRINDEX, SQL_FUNC_STRINDEXFROM, SQL_FUNC_SUBSTRING, SQL_FUNC_SUBSTRINGEX, SQL_FUNC_SUM, SQL_FUNC_TRIM, SQL_FUNC_TRUNC, SQL_FUNC_UPPER, SQL_FUNC_YEAR, SQL_NULL_VALUE, SQL_PARAMETER, SQL_PSEUDO_TABLE, SQL_QUOTES_CLOSE, SQL_QUOTES_OPEN, SQL_RENAME_COLUMN, SQL_RENAME_TABLE, SQL_TIMESTAMP_PATTERN, SQL_TIMESTAMP_TEMPLATE
Constructor and Description |
---|
DBDatabaseDriverMSSQL()
Constructor for the MSSQL database driver.
|
Modifier and Type | Method and Description |
---|---|
void |
addEnableRelationStmt(DBRelation r,
boolean enable,
DBSQLScript script)
Appends a statement to enable or disable a foreign key relation.
|
protected void |
addStatementParam(PreparedStatement pstmt,
int paramIndex,
Object value)
Adds special behaviour for Timestamp columns with are declared as DATETIME
|
protected void |
attachDatabase(DBDatabase db,
Connection conn)
Called when a database is opened
|
DBCommand |
createCommand(DBDatabase db)
Creates a new Microsoft SQL-Server command object.
|
Object |
getColumnAutoValue(DBDatabase db,
DBTableColumn column,
Connection conn)
Returns an auto-generated value for a particular column
|
String |
getConvertPhrase(DataType destType,
DataType srcType,
Object format)
Returns a data type convertion phrase template for this driver
The returned template must contain a '?' |
String |
getDatabaseName() |
void |
getDDLScript(DBCmdType type,
DBObject dbo,
DBSQLScript script)
Appends the required DLL commands to create, drop or alter an object to the supplied DBDQLScript.
|
Object |
getNextSequenceValue(DBDatabase db,
String seqName,
int minValue,
Connection conn)
Returns the next value of a named sequence The numbers are used for fields of type DBExpr.DT_AUTOINC.
|
DBColumnExpr |
getNextSequenceValueExpr(DBTableColumn column)
Returns an expression for creating a sequence value.
|
String |
getObjectOwner() |
String |
getSequenceTableName()
returns the name of the sequence table
|
String |
getSQLPhrase(int phrase)
Gets an sql phrase template for this database system.
|
protected String |
getSQLTextString(DataType type,
Object value)
encodes Text values for an SQL command string.
|
Timestamp |
getUpdateTimestamp(Connection conn)
Overridden.
|
boolean |
isSupported(DBDriverFeature type)
Returns whether or not a particular feature is supported by this driver
|
boolean |
isUseDateTime2()
returns whether the DATETIME2 datatype is used for timestamps (instead of DATETIME)
|
boolean |
isUseSequenceTable()
returns whether a sequence table is used for record identiy management.
|
boolean |
isUseUnicodePrefix()
Indicates whether or not a Unicode Prefix (N) is prepended to all text values
|
void |
setDatabaseName(String databaseName) |
void |
setObjectOwner(String objectOwner) |
void |
setSequenceTableName(String sequenceTableName)
Sets the name of the sequence table.
|
void |
setUseDateTime2(boolean useDateTime2)
Sets whether or not to use the DATETIME2 datatype instead of DATETIME for timestamps
Default is true (set to false for existing databases using DATETIME!)
|
void |
setUseSequenceTable(boolean useSequenceTable)
If set to true a special table is used for sequence number generation.
|
void |
setUseUnicodePrefix(boolean useUnicodePrefix)
Sets whether or not to use a Unicode Prefix (N) for all text values
Default is true
|
appendElementName, appendElementName, appendSQLTextValue, checkDatabase, close, createCombinedCommand, detachDatabase, detectQuoteName, executeBatch, executeQuery, executeSQL, extractErrorMessage, getResultValue, getSQLDateTimeString, getSQLNumberString, getValueString, isDDLColumnDefaults, prepareStatement, setDDLColumnDefaults, stringToBoolean
protected DBDDLGenerator<?> ddlGenerator
protected static final String[] MSSQL_SQL_KEYWORDS
public DBDatabaseDriverMSSQL()
public String getDatabaseName()
public void setDatabaseName(String databaseName)
public String getObjectOwner()
public void setObjectOwner(String objectOwner)
public boolean isUseSequenceTable()
public void setUseSequenceTable(boolean useSequenceTable)
useSequenceTable
- true to use a sequence table or false otherwise.public String getSequenceTableName()
public void setSequenceTableName(String sequenceTableName)
sequenceTableName
- the name of the table used for sequence number generationpublic boolean isUseUnicodePrefix()
public void setUseUnicodePrefix(boolean useUnicodePrefix)
useUnicodePrefix
- true if a Unicode Prefix (N) should be used for text valuespublic boolean isUseDateTime2()
public void setUseDateTime2(boolean useDateTime2)
useDateTime2
- true if DATETIME2 or false if DATETIME is usedprotected void attachDatabase(DBDatabase db, Connection conn)
attachDatabase
in class DBDatabaseDriver
public DBCommand createCommand(DBDatabase db)
createCommand
in class DBDatabaseDriver
db
- the database for which to create a command object forpublic boolean isSupported(DBDriverFeature type)
isSupported
in class DBDatabaseDriver
type
- type of requested feature. @see DBDriverFeaturepublic String getSQLPhrase(int phrase)
getSQLPhrase
in class DBDatabaseDriver
phrase
- the identifier of the phraseDBDatabaseDriver.getSQLPhrase(int)
public String getConvertPhrase(DataType destType, DataType srcType, Object format)
DBDatabaseDriver
getConvertPhrase
in class DBDatabaseDriver
destType
- the target data typesrcType
- the source data typeformat
- additional formatting information (optional)DBDatabaseDriver.getConvertPhrase(DataType, DataType, Object)
public Object getNextSequenceValue(DBDatabase db, String seqName, int minValue, Connection conn)
DBDatabaseDriver
getNextSequenceValue
in class DBDatabaseDriver
db
- the databaseseqName
- the name of the sequenceminValue
- the minimum value of the sequenceconn
- a valid database connectionDBDatabaseDriver.getNextSequenceValue(DBDatabase, String, int, Connection)
public DBColumnExpr getNextSequenceValueExpr(DBTableColumn column)
DBDatabaseDriver
getNextSequenceValueExpr
in class DBDatabaseDriver
DBDatabaseDriver.getNextSequenceValueExpr(DBTableColumn col)
protected String getSQLTextString(DataType type, Object value)
DBDatabaseDriver
getSQLTextString
in class DBDatabaseDriver
type
- date type (can only be TEXT, CHAR, CLOB and UNIQUEID)value
- the text to be encodedDBDatabaseDriver.getSQLTextString(DataType type, Object value)
public Timestamp getUpdateTimestamp(Connection conn)
getUpdateTimestamp
in class DBDatabaseDriver
conn
- the connection that might be usedpublic Object getColumnAutoValue(DBDatabase db, DBTableColumn column, Connection conn)
getColumnAutoValue
in class DBDatabaseDriver
db
- the databasecolumn
- the column for which a value is requiredconn
- a valid database connectionprotected void addStatementParam(PreparedStatement pstmt, int paramIndex, Object value) throws SQLException
addStatementParam
in class DBDatabaseDriver
pstmt
- the prepared statementparamIndex
- the parameter indexvalue
- the parameter valueSQLException
public void getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
DBDatabaseDriver
getDDLScript
in class DBDatabaseDriver
type
- operation to perform (CREATE, DROP, ALTER)dbo
- the object for which to perform the operation (DBDatabase, DBTable, DBView, DBColumn, DBRelation)script
- the script to which to add the DDL command(s)DBDatabaseDriver.getDDLScript(DBCmdType, DBObject, DBSQLScript)
public void addEnableRelationStmt(DBRelation r, boolean enable, DBSQLScript script)
DBDatabaseDriver
addEnableRelationStmt
in class DBDatabaseDriver
r
- the foreign key relation which should be enabled or disabledenable
- true to enable the relation or false to disablescript
- the script to which to add the DDL command(s)DBDatabaseDriver.addEnableRelationStmt(DBRelation, boolean, DBSQLScript)
Copyright © 2008–2022 Apache Software Foundation. All rights reserved.