org.apache.empire.db.sqlserver
Class DBDatabaseDriverMSSQL

java.lang.Object
  extended by org.apache.empire.db.DBDatabaseDriver
      extended by org.apache.empire.db.sqlserver.DBDatabaseDriverMSSQL
All Implemented Interfaces:
Serializable

public class DBDatabaseDriverMSSQL
extends DBDatabaseDriver

This class provides support for the Microsoft SQL-Server database system.

See Also:
Serialized Form

Nested Class Summary
static class DBDatabaseDriverMSSQL.DBCommandMSSQL
          Defines the Microsoft SQL-Server command type.
 
Nested classes/interfaces inherited from class org.apache.empire.db.DBDatabaseDriver
DBDatabaseDriver.DBSeqTable, DBDatabaseDriver.DBSetGenKeys
 
Field Summary
protected static String[] MSSQL_SQL_KEYWORDS
           
 
Fields inherited from class org.apache.empire.db.DBDatabaseDriver
ddlColumnDefaults, GENERAL_SQL_KEYWORDS, ILLEGAL_NAME_CHARS, reservedSQLKeywords, SQL_BOOLEAN_FALSE, SQL_BOOLEAN_TRUE, SQL_CONCAT_EXPR, SQL_CURRENT_DATE, SQL_CURRENT_DATETIME, 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_LENGTH, SQL_FUNC_LOWER, SQL_FUNC_LTRIM, SQL_FUNC_MAX, SQL_FUNC_MIN, 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_QUOTES_CLOSE, SQL_QUOTES_OPEN, SQL_RENAME_COLUMN, SQL_RENAME_TABLE
 
Constructor Summary
DBDatabaseDriverMSSQL()
          Constructor for the MSSQL database driver.
 
Method Summary
 void addEnableRelationStmt(DBRelation r, boolean enable, DBSQLScript script)
          Appends a statement to enable or disable a foreign key relation.
The default is to drop or create the relation Override this method to provide different behavior for your database.
 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 '?' which will be replaced by a column expression.
 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.
If a driver supports this function it must return true for isSupported(DBDriverFeature.SEQUENCES).
 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 isUseSequenceTable()
          returns whether a sequence table is used for record identiy management.
Default is false.
 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 setUseSequenceTable(boolean useSequenceTable)
          If set to true a special table is used for sequence number generation.
Otherwise the AutoIncrement feature of MySQL is used identiy fields.
 void setUseUnicodePrefix(boolean useUnicodePrefix)
          Sets whether or not to use a Unicode Prefix (N) for all text values Default is true
 
Methods inherited from class org.apache.empire.db.DBDatabaseDriver
addStatementParam, appendElementName, appendElementName, appendSQLTextValue, checkDatabase, close, createCombinedCommand, detachDatabase, detectQuoteName, executeQuery, executeSQL, extractErrorMessage, getResultValue, getSQLDateTimeString, getSQLNumberString, getValueString, isDDLColumnDefaults, prepareStatement, setDDLColumnDefaults, stringToBoolean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSSQL_SQL_KEYWORDS

protected static final String[] MSSQL_SQL_KEYWORDS
Constructor Detail

DBDatabaseDriverMSSQL

public DBDatabaseDriverMSSQL()
Constructor for the MSSQL database driver.

Method Detail

getDatabaseName

public String getDatabaseName()

setDatabaseName

public void setDatabaseName(String databaseName)

getObjectOwner

public String getObjectOwner()

setObjectOwner

public void setObjectOwner(String objectOwner)

isUseSequenceTable

public boolean isUseSequenceTable()
returns whether a sequence table is used for record identiy management.
Default is false. In this case the AutoIncrement feature of MySQL is used.

Returns:
true if a sequence table is used instead of identity columns.

setUseSequenceTable

public void setUseSequenceTable(boolean useSequenceTable)
If set to true a special table is used for sequence number generation.
Otherwise the AutoIncrement feature of MySQL is used identiy fields.

Parameters:
useSequenceTable - true to use a sequence table or false otherwise.

getSequenceTableName

public String getSequenceTableName()
returns the name of the sequence table

Returns:
the name of the table used for sequence number generation

setSequenceTableName

public void setSequenceTableName(String sequenceTableName)
Sets the name of the sequence table.

Parameters:
sequenceTableName - the name of the table used for sequence number generation

isUseUnicodePrefix

public boolean isUseUnicodePrefix()
Indicates whether or not a Unicode Prefix (N) is prepended to all text values


setUseUnicodePrefix

public void setUseUnicodePrefix(boolean useUnicodePrefix)
Sets whether or not to use a Unicode Prefix (N) for all text values Default is true

Parameters:
useUnicodePrefix - true if a Unicode Prefix (N) should be used for text values

attachDatabase

public void attachDatabase(DBDatabase db,
                           Connection conn)
Called when a database is opened

Overrides:
attachDatabase in class DBDatabaseDriver

createCommand

public DBCommand createCommand(DBDatabase db)
Creates a new Microsoft SQL-Server command object.

Specified by:
createCommand in class DBDatabaseDriver
Parameters:
db - the database for which to create a command object for
Returns:
the new DBCommandMSSQL object

isSupported

public boolean isSupported(DBDriverFeature type)
Returns whether or not a particular feature is supported by this driver

Specified by:
isSupported in class DBDatabaseDriver
Parameters:
type - type of requested feature. @see DBDriverFeature
Returns:
true if the features is supported or false otherwise

getSQLPhrase

public String getSQLPhrase(int phrase)
Gets an sql phrase template for this database system.

Specified by:
getSQLPhrase in class DBDatabaseDriver
Parameters:
phrase - the identifier of the phrase
Returns:
the phrase template
See Also:
DBDatabaseDriver.getSQLPhrase(int)

getConvertPhrase

public String getConvertPhrase(DataType destType,
                               DataType srcType,
                               Object format)
Description copied from class: DBDatabaseDriver
Returns a data type convertion phrase template for this driver
The returned template must contain a '?' which will be replaced by a column expression.

Specified by:
getConvertPhrase in class DBDatabaseDriver
Parameters:
destType - the target data type
srcType - the source data type
format - additional formatting information (optional)
Returns:
the data conversion phrase template
See Also:
DBDatabaseDriver.getConvertPhrase(DataType, DataType, Object)

getNextSequenceValue

public Object getNextSequenceValue(DBDatabase db,
                                   String seqName,
                                   int minValue,
                                   Connection conn)
Description copied from class: DBDatabaseDriver
Returns the next value of a named sequence The numbers are used for fields of type DBExpr.DT_AUTOINC.
If a driver supports this function it must return true for isSupported(DBDriverFeature.SEQUENCES).

Specified by:
getNextSequenceValue in class DBDatabaseDriver
Parameters:
db - the database
seqName - the name of the sequence
minValue - the minimum value of the sequence
conn - a valid database connection
Returns:
a new unique sequence value or null if an error occurred
See Also:
DBDatabaseDriver.getNextSequenceValue(DBDatabase, String, int, Connection)

getSQLTextString

protected String getSQLTextString(DataType type,
                                  Object value)
Description copied from class: DBDatabaseDriver
encodes Text values for an SQL command string.

Overrides:
getSQLTextString in class DBDatabaseDriver
Parameters:
type - date type (can only be TEXT, CHAR, CLOB and UNIQUEID)
value - the text to be encoded
Returns:
the encoded sql value
See Also:
DBDatabaseDriver.getSQLTextString(DataType type, Object value)

getUpdateTimestamp

public Timestamp getUpdateTimestamp(Connection conn)
Overridden. Returns a timestamp that is used for record updates created by the database server.

Overrides:
getUpdateTimestamp in class DBDatabaseDriver
Parameters:
conn - the connection that might be used
Returns:
the current date and time of the database server.

getColumnAutoValue

public Object getColumnAutoValue(DBDatabase db,
                                 DBTableColumn column,
                                 Connection conn)
Returns an auto-generated value for a particular column

Overrides:
getColumnAutoValue in class DBDatabaseDriver
Parameters:
db - the database
column - the column for which a value is required
conn - a valid database connection
Returns:
the auto-generated value

getDDLScript

public void getDDLScript(DBCmdType type,
                         DBObject dbo,
                         DBSQLScript script)
Description copied from class: DBDatabaseDriver
Appends the required DLL commands to create, drop or alter an object to the supplied DBDQLScript.

Overrides:
getDDLScript in class DBDatabaseDriver
Parameters:
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)
See Also:
DBDatabaseDriver.getDDLScript(DBCmdType, DBObject, DBSQLScript)

addEnableRelationStmt

public void addEnableRelationStmt(DBRelation r,
                                  boolean enable,
                                  DBSQLScript script)
Description copied from class: DBDatabaseDriver
Appends a statement to enable or disable a foreign key relation.
The default is to drop or create the relation Override this method to provide different behavior for your database.

Overrides:
addEnableRelationStmt in class DBDatabaseDriver
Parameters:
r - the foreign key relation which should be enabled or disabled
enable - true to enable the relation or false to disable
script - the script to which to add the DDL command(s)
See Also:
DBDatabaseDriver.addEnableRelationStmt(DBRelation, boolean, DBSQLScript)


Copyright © 2008–2014 Apache Software Foundation. All rights reserved.