org.apache.empire.db.oracle
Class DBDatabaseDriverOracle

java.lang.Object
  extended by org.apache.empire.commons.ErrorObject
      extended by org.apache.empire.db.DBDatabaseDriver
          extended by org.apache.empire.db.oracle.DBDatabaseDriverOracle
All Implemented Interfaces:
java.io.Serializable, ErrorInfo

public class DBDatabaseDriverOracle
extends DBDatabaseDriver

This class provides support for the Oracle database system.
Oracle Version 9 or higher is required.

See Also:
Serialized Form

Nested Class Summary
static class DBDatabaseDriverOracle.BooleanType
           
 
Nested classes/interfaces inherited from class org.apache.empire.db.DBDatabaseDriver
DBDatabaseDriver.DBSeqTable, DBDatabaseDriver.DBSetGenKeys
 
Nested classes/interfaces inherited from class org.apache.empire.commons.ErrorObject
ErrorObject.ObjectErrorInfo
 
Field Summary
 
Fields inherited from class org.apache.empire.db.DBDatabaseDriver
ddlColumnDefaults, GENERAL_SQL_KEYWORDS, ILLEGAL_NAME_CHARS, log, 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
DBDatabaseDriverOracle()
          Constructor for the Oracle database driver.
 
Method Summary
protected  boolean alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
          Creates an alter table dll statement for adding, modifiying or droping a column.
protected  boolean appendColumnDesc(DBTableColumn c, java.lang.StringBuilder sql)
          Appends a table column definition to a ddl statement
 boolean checkDatabase(DBDatabase db, java.lang.String owner, java.sql.Connection conn)
          Checks whether the database definition matches the real database structure.
 DBCommand createCommand(DBDatabase db)
          Creates a new Oracle command object.
protected  boolean createComment(DBDatabase db, java.lang.String type, DBExpr expr, java.lang.String comment, DBSQLScript script)
          Returns true if the comment has been created successfully.
protected  boolean createDatabase(DBDatabase db, DBSQLScript script)
          Returns true if the database has been created successfully.
protected  boolean createRelation(DBRelation r, DBSQLScript script)
          Create a sql string for creating a relation and appends it to the supplied buffer
protected  boolean createSequence(DBDatabase db, DBTableColumn c, DBSQLScript script)
          Returns true if the sequence has been created successfully.
protected  boolean createTable(DBTable t, DBSQLScript script)
          Returns true if the table has been created successfully.
protected  boolean createView(DBView v, DBSQLScript script)
          Returns true if the view has been created successfully.
protected  boolean dropObject(java.lang.String name, java.lang.String objType, DBSQLScript script)
          Returns true if the object has been dropped successfully.
 java.lang.String extractErrorMessage(java.sql.SQLException sqle)
          Extracts native error message of an sqlExeption.
 DBDatabaseDriverOracle.BooleanType getBooleanType()
           
 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.
 boolean getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
          Gets a SQL command for creating, modifying or deleting objects in the database (tables, columns, constraints, etc.)
 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)
          Gets the value of a sql ResultSet.
 java.lang.String getSQLPhrase(int phrase)
          Gets an sql phrase template for this database system.
 java.sql.Timestamp getUpdateTimestamp(java.sql.Connection conn)
          Overridden.
 boolean isOracle8Compatibilty()
           
 boolean isSupported(DBDriverFeature type)
          Returns whether or not a particular feature is supported by this driver
 void setBooleanType(DBDatabaseDriverOracle.BooleanType booleanType)
           
 void setOracle8Compatibilty(boolean oracle8Compatibilty)
           
 
Methods inherited from class org.apache.empire.db.DBDatabaseDriver
appendElementName, appendElementName, appendTextValue, attachDatabase, close, detachDatabase, detectQuoteName, executeQuery, executeSQL, getColumnAutoValue, getDateTimeString, getValueString, isDDLColumnDefaults, prepareStatement, setDDLColumnDefaults
 
Methods inherited from class org.apache.empire.commons.ErrorObject
clearError, clearErrorInfo, 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
 

Constructor Detail

DBDatabaseDriverOracle

public DBDatabaseDriverOracle()
Constructor for the Oracle database driver.

Method Detail

isOracle8Compatibilty

public boolean isOracle8Compatibilty()

setOracle8Compatibilty

public void setOracle8Compatibilty(boolean oracle8Compatibilty)

getBooleanType

public DBDatabaseDriverOracle.BooleanType getBooleanType()

setBooleanType

public void setBooleanType(DBDatabaseDriverOracle.BooleanType booleanType)

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 requrested feature. @see DBDriverFeature
Returns:
true if the features is supported or false otherwise

createCommand

public DBCommand createCommand(DBDatabase db)
Creates a new Oracle command object.

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

getSQLPhrase

public java.lang.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 java.lang.String getConvertPhrase(DataType destType,
                                         DataType srcType,
                                         java.lang.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)

extractErrorMessage

public java.lang.String extractErrorMessage(java.sql.SQLException sqle)
Extracts native error message of an sqlExeption.

Overrides:
extractErrorMessage in class DBDatabaseDriver
Parameters:
sqle - the SQLException
Returns:
the error message of the database

getResultValue

public java.lang.Object getResultValue(java.sql.ResultSet rset,
                                       int columnIndex,
                                       DataType dataType)
                                throws java.sql.SQLException
Gets the value of a sql ResultSet. Gives the driver the oportunity to change the value i.e. to simulate missing data types with other types.

Overrides:
getResultValue in class DBDatabaseDriver
Parameters:
rset - the sql Resultset with the current data row
columnIndex - one based column Index of the desired column
dataType - the desired data type
Returns:
the value of the column
Throws:
java.sql.SQLException - if a database access error occurs

getNextSequenceValue

public java.lang.Object getNextSequenceValue(DBDatabase db,
                                             java.lang.String seqName,
                                             int minValue,
                                             java.sql.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)

getDDLScript

public boolean getDDLScript(DBCmdType type,
                            DBObject dbo,
                            DBSQLScript script)
Description copied from class: DBDatabaseDriver
Gets a SQL command for creating, modifying or deleting objects in the database (tables, columns, constraints, etc.)

Overrides:
getDDLScript in class DBDatabaseDriver
Parameters:
type - the command type
dbo - the databse object
script - the script to complete
Returns:
true on succes
See Also:
DBDatabaseDriver.getDDLScript(DBCmdType, DBObject, DBSQLScript)

getUpdateTimestamp

public java.sql.Timestamp getUpdateTimestamp(java.sql.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.

createDatabase

protected boolean createDatabase(DBDatabase db,
                                 DBSQLScript script)
Returns true if the database has been created successfully.

Returns:
true if the database has been created successfully

createSequence

protected boolean createSequence(DBDatabase db,
                                 DBTableColumn c,
                                 DBSQLScript script)
Returns true if the sequence has been created successfully.

Returns:
true if the sequence has been created successfully

createTable

protected boolean createTable(DBTable t,
                              DBSQLScript script)
Returns true if the table has been created successfully.

Returns:
true if the table has been created successfully

appendColumnDesc

protected boolean appendColumnDesc(DBTableColumn c,
                                   java.lang.StringBuilder sql)
Appends a table column definition to a ddl statement

Parameters:
c - the column which description to append
sql - the sql builder object
Returns:
true if the column was successfully appended or false otherwise

createRelation

protected boolean createRelation(DBRelation r,
                                 DBSQLScript script)
Create a sql string for creating a relation and appends it to the supplied buffer

Returns:
true if the relation has been created successfully

alterTable

protected boolean alterTable(DBTableColumn col,
                             DBCmdType type,
                             DBSQLScript script)
Creates an alter table dll statement for adding, modifiying or droping a column.

Parameters:
col - the column which to add, modify or drop
type - the type of operation to perform
script - to which to append the sql statement to
Returns:
true if the statement was successfully appended to the buffer

createView

protected boolean createView(DBView v,
                             DBSQLScript script)
Returns true if the view has been created successfully.

Returns:
true if the view has been created successfully

createComment

protected boolean createComment(DBDatabase db,
                                java.lang.String type,
                                DBExpr expr,
                                java.lang.String comment,
                                DBSQLScript script)
Returns true if the comment has been created successfully.

Returns:
true if the comment has been created successfully

dropObject

protected boolean dropObject(java.lang.String name,
                             java.lang.String objType,
                             DBSQLScript script)
Returns true if the object has been dropped successfully.

Returns:
true if the object has been dropped successfully

checkDatabase

public boolean checkDatabase(DBDatabase db,
                             java.lang.String owner,
                             java.sql.Connection conn)
Checks whether the database definition matches the real database structure.

Overrides:
checkDatabase in class DBDatabaseDriver
Parameters:
db - the database
owner - the owner
conn - the connection
Returns:
true if the database definition matches the real database structure.


Copyright © 2008-2011 Apache Software Foundation. All Rights Reserved.