|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.empire.commons.ErrorObject
org.apache.empire.db.DBDatabaseDriver
public abstract class DBDatabaseDriver
Nested Class Summary | |
---|---|
static class |
DBDatabaseDriver.DBSeqTable
This class is used to emulate sequences by using a sequence table. |
static interface |
DBDatabaseDriver.DBSetGenKeys
This interface is used to set the auto generated keys when executing insert statements. |
Nested classes/interfaces inherited from class org.apache.empire.commons.ErrorObject |
---|
ErrorObject.ObjectErrorInfo |
Constructor Summary | |
---|---|
DBDatabaseDriver()
Constructor |
Method Summary | |
---|---|
void |
appendElementName(java.lang.StringBuilder sql,
java.lang.String name)
Appends a table, view or column name to an SQL phrase. |
void |
appendElementName(java.lang.StringBuilder sql,
java.lang.String name,
boolean useQuotes)
Appends a table, view or column name to an SQL phrase. |
protected void |
appendTextValue(java.lang.StringBuilder buf,
java.lang.String value)
this helper function doubles up single quotes for SQL |
protected boolean |
attachDatabase(DBDatabase db,
java.sql.Connection conn)
Called when a database is opened |
boolean |
checkDatabase(DBDatabase db,
java.lang.String owner,
java.sql.Connection conn)
Checks the database whether or not it is consistent with the description. |
protected void |
close(java.sql.Statement stmt)
|
abstract DBCommand |
createCommand(DBDatabase db)
This function creates a DBCommand derived object this database |
protected void |
detachDatabase(DBDatabase db,
java.sql.Connection conn)
Called when a database is closed |
protected boolean |
detectQuoteName(java.lang.String name)
Detects wether a table or column name needs to be quoted or not By default all reserved SQL keywords as well as names containing a "-", "/", "+" or " " require quoting. Overrides this function to add database specific keywords like "user" or "count" |
java.sql.ResultSet |
executeQuery(java.lang.String sqlCmd,
java.lang.Object[] sqlParams,
boolean scrollable,
java.sql.Connection conn)
|
int |
executeSQL(java.lang.String sqlCmd,
java.lang.Object[] sqlParams,
java.sql.Connection conn,
DBDatabaseDriver.DBSetGenKeys genKeys)
Executes the select, update or delete SQL-Command with a Statement object. |
java.lang.String |
extractErrorMessage(java.sql.SQLException e)
Extracts native error message of an sqlExeption. |
java.lang.Object |
getColumnAutoValue(DBDatabase db,
DBTableColumn column,
java.sql.Connection conn)
Returns an auto-generated value for a particular column |
abstract java.lang.String |
getConvertPhrase(DataType destType,
DataType srcType,
java.lang.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. |
protected java.lang.String |
getDateTimeString(java.lang.Object value,
int sqlTemplate,
int sqlPattern,
int sqlCurrentDate)
|
boolean |
getDDLScript(DBCmdType type,
DBObject dbo,
DBSQLScript script)
gets an SQL command for creating, modifying or deleting objects in the database (tables, columns, constraints, etc.) |
abstract java.lang.Object |
getNextSequenceValue(DBDatabase db,
java.lang.String SeqName,
int minValue,
java.sql.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). |
java.lang.Object |
getResultValue(java.sql.ResultSet rset,
int columnIndex,
DataType dataType)
Reads a sinlge column value from the given JDBC ResultSet and returns a value object of desired data type. See DBExpr.getValueClass(DataType) for java class type mapping. |
abstract java.lang.String |
getSQLPhrase(int phrase)
Returns an sql phrase template for this database system. Templates for sql function expressions must contain a '?' character which will be replaced by the current column expression. If other parameters are necessary the template must contain placeholders like {0}, {1} etc. |
java.sql.Timestamp |
getUpdateTimestamp(java.sql.Connection conn)
Returns a timestamp that is used for record updates. |
java.lang.String |
getValueString(java.lang.Object value,
DataType type)
Creates a sql string for a given value. |
boolean |
isDDLColumnDefaults()
|
abstract boolean |
isSupported(DBDriverFeature type)
Returns whether or not a particular feature is supported by this driver |
protected void |
prepareStatement(java.sql.PreparedStatement pstmt,
java.lang.Object[] sqlParams)
Prepares an sql statement by setting the supplied objects as parameters. |
void |
setDDLColumnDefaults(boolean enable)
Set true if column default values should be included in DDL Statements |
Methods inherited from class org.apache.empire.commons.ErrorObject |
---|
clearError, clearErrorInfo, error, error, error, error, error, error, error, getErrorInfo, getErrorMessage, getErrorParams, getErrorSource, getErrorType, getMessage, hasError, internalSetError, isExceptionsEnabled, setExceptionsEnabled, success |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SQL_NULL_VALUE
public static final int SQL_PARAMETER
public static final int SQL_RENAME_TABLE
public static final int SQL_RENAME_COLUMN
public static final int SQL_DATABASE_LINK
public static final int SQL_QUOTES_OPEN
public static final int SQL_QUOTES_CLOSE
public static final int SQL_CONCAT_EXPR
public static final int SQL_BOOLEAN_TRUE
public static final int SQL_BOOLEAN_FALSE
public static final int SQL_CURRENT_DATE
public static final int SQL_DATE_PATTERN
public static final int SQL_DATE_TEMPLATE
public static final int SQL_CURRENT_DATETIME
public static final int SQL_DATETIME_PATTERN
public static final int SQL_DATETIME_TEMPLATE
public static final int SQL_FUNC_COALESCE
public static final int SQL_FUNC_SUBSTRING
public static final int SQL_FUNC_SUBSTRINGEX
public static final int SQL_FUNC_REPLACE
public static final int SQL_FUNC_REVERSE
public static final int SQL_FUNC_STRINDEX
public static final int SQL_FUNC_STRINDEXFROM
public static final int SQL_FUNC_LENGTH
public static final int SQL_FUNC_UPPER
public static final int SQL_FUNC_LOWER
public static final int SQL_FUNC_TRIM
public static final int SQL_FUNC_LTRIM
public static final int SQL_FUNC_RTRIM
public static final int SQL_FUNC_ESCAPE
public static final int SQL_FUNC_ABS
public static final int SQL_FUNC_ROUND
public static final int SQL_FUNC_TRUNC
public static final int SQL_FUNC_FLOOR
public static final int SQL_FUNC_CEILING
public static final int SQL_FUNC_DAY
public static final int SQL_FUNC_MONTH
public static final int SQL_FUNC_YEAR
public static final int SQL_FUNC_SUM
public static final int SQL_FUNC_MAX
public static final int SQL_FUNC_MIN
public static final int SQL_FUNC_AVG
public static final int SQL_FUNC_DECODE
public static final int SQL_FUNC_DECODE_SEP
public static final int SQL_FUNC_DECODE_PART
public static final int SQL_FUNC_DECODE_ELSE
protected static final org.apache.commons.logging.Log log
protected boolean ddlColumnDefaults
protected static final char[] illegalNameChars
protected static final java.lang.String[] generalSQLKeywords
protected final java.util.Set<java.lang.String> reservedSQLKeywords
Constructor Detail |
---|
public DBDatabaseDriver()
Method Detail |
---|
public abstract DBCommand createCommand(DBDatabase db)
db
- the database for which to create a command object for
public abstract boolean isSupported(DBDriverFeature type)
type
- type of requrested feature. @see DBDriverFeature
protected boolean detectQuoteName(java.lang.String name)
public void appendElementName(java.lang.StringBuilder sql, java.lang.String name, boolean useQuotes)
sql
- the StringBuilder containing the SQL phrase.name
- the name of the object (table, view or column)useQuotes
- use quotes or notpublic final void appendElementName(java.lang.StringBuilder sql, java.lang.String name)
sql
- the StringBuilder containing the SQL phrase.name
- the name of the object (table, view or column)public abstract java.lang.String getSQLPhrase(int phrase)
phrase
- the identifier of the phrase
public abstract java.lang.String getConvertPhrase(DataType destType, DataType srcType, java.lang.Object format)
destType
- the target data typesrcType
- the source data typeformat
- additional formatting information (optional)
public abstract java.lang.Object getNextSequenceValue(DBDatabase db, java.lang.String SeqName, int minValue, java.sql.Connection conn)
db
- the databaseSeqName
- the name of the sequenceminValue
- the minmum value of the sequenceconn
- a valid database connection
public java.lang.Object getColumnAutoValue(DBDatabase db, DBTableColumn column, java.sql.Connection conn)
db
- the databasecolumn
- the column for which a value is requiredconn
- a valid database connection
protected void prepareStatement(java.sql.PreparedStatement pstmt, java.lang.Object[] sqlParams) throws java.sql.SQLException
pstmt
- the prepared statementsqlParams
- list of objects
java.sql.SQLException
public java.lang.String extractErrorMessage(java.sql.SQLException e)
e
- the SQLException
public java.lang.Object getResultValue(java.sql.ResultSet rset, int columnIndex, DataType dataType) throws java.sql.SQLException
Reads a sinlge column value from the given JDBC ResultSet and returns a value object of desired data type.
See DBExpr.getValueClass(DataType)
for java class type mapping.
This gives the driver the oportunity to change the value i.e. to simulate missing data types with other types.
rset
- the sql Resultset with the current data rowcolumnIndex
- one based column Index of the desired columndataType
- the required data type
java.sql.SQLException
- if a database access error occurspublic int executeSQL(java.lang.String sqlCmd, java.lang.Object[] sqlParams, java.sql.Connection conn, DBDatabaseDriver.DBSetGenKeys genKeys) throws java.sql.SQLException
sqlCmd
- the SQL-CommandsqlParams
- array of sql command parameters used for prepared statements (Optional).conn
- a valid connection to the database.genKeys
- allows to set the auto generated key of a record (INSERT statements only)
java.sql.SQLException
- if a database access error occurspublic java.sql.ResultSet executeQuery(java.lang.String sqlCmd, java.lang.Object[] sqlParams, boolean scrollable, java.sql.Connection conn) throws java.sql.SQLException
java.sql.SQLException
protected void close(java.sql.Statement stmt)
protected java.lang.String getDateTimeString(java.lang.Object value, int sqlTemplate, int sqlPattern, int sqlCurrentDate)
public final java.lang.String getValueString(java.lang.Object value, DataType type)
value
- the value which is inserted to the new Stringtype
- the sql data type of the supplied value
protected boolean attachDatabase(DBDatabase db, java.sql.Connection conn)
protected void detachDatabase(DBDatabase db, java.sql.Connection conn)
public boolean checkDatabase(DBDatabase db, java.lang.String owner, java.sql.Connection conn)
db
- the databaseowner
- the ownerconn
- the connection
public boolean getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
type
- the command typedbo
- the databse objectscript
- the script to complete
public boolean isDDLColumnDefaults()
public void setDDLColumnDefaults(boolean enable)
enable
- true if dll statements should include column default values or false if notpublic java.sql.Timestamp getUpdateTimestamp(java.sql.Connection conn)
conn
- the connection that might be used
protected void appendTextValue(java.lang.StringBuilder buf, java.lang.String value)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |