Package org.compiere.db
Class DB_Oracle
java.lang.Object
org.compiere.db.DB_Oracle
- All Implemented Interfaces:
AdempiereDatabase
Oracle Database Port
- Version:
- $Id: DB_Oracle.java,v 1.7 2006/09/22 23:35:19 jjanke Exp $ --- Modifications: Refactoring. Replaced Oracle Cache Manager with C3P0 connection pooling framework for better and more efficient connection handling
- Author:
- Jorg Janke, Ashley Ramdass (Posterita)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault Connection Manager Portstatic final intDefault Portstatic final StringDriver Class NameFields inherited from interface org.compiere.db.AdempiereDatabase
CMD_CREATE_DATABASE, CMD_CREATE_USER, CMD_DROP_DATABASE, LOCK_TIME_OUT, MAX_OBJECT_NAME_LENGTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPagingSQL(String sql, int start, int end) Implemented using the fetch first and offset feature. use 1 base index for start and end parametervoidcleanup()Clean upvoidclose()CloseconvertStatement(String oraStatement) Convert an individual Oracle Style statements to target database statement syntax.booleancreateSequence(String name, int increment, int minvalue, int maxvalue, int start, String trxName) Create Native SequencebooleanLock PO for updategetAlternativeSQL(int reExNo, String msg, String sql) Check and generate an alternative SQLgetCachedConnection(CConnection connection, boolean autoCommit, int transactionIsolation) Get Cached ConnectionGet JDBC CatalogString[]getCommands(int cmdType) Get SQL Commands.getConnectionURL(String dbHost, int dbPort, String dbName, String userName) Get Connection URL.getConnectionURL(String connectionURL, String userName) Get Database Connection StringgetConnectionURL(CConnection connection) Get Database Connection String.getConstraintType(Connection conn, String tableName, String IXName) Get constraint type associated with the indexGetConvertimplementation for this DB adaptergetDataSource(CConnection connection) Create DataSourcegetDataType(String columnName, int displayType, int precision, boolean defaultValue) Deprecated.Get Database DescriptionGet and register Database DrivergetDriverConnection(String dbUrl, String dbUid, String dbPwd) Get Driver ConnectiongetDriverConnection(CConnection connection) Get Connection from DriverThe "child record found error" contains the foreign key constraint name after the second occurrence of the opening double quote: ["].getName()Get Database NameintGet next sequence number in this SequenceintGet next sequence number in this SequenceGet JDBC SchemaGet SQL Add commandgetSQLModify(MTable table, MColumn column, boolean setNullOption) Get SQL Modify commandintGet Standard JDBC PortGet StatusgetSystemDatabase(String databaseName) Get Name of System DatabaseGet Name of System UserGet DB specific table partition supportintersectClauseForCSV(String columnName, String csv) intersectClauseForCSV(String columnName, String csv, boolean isNotClause) booleanIs the database have sql extension that return a subset of the query resultbooleanbooleanbooleanisSupported(String sql) Check if DBMS support the sql statementsubsetClauseForCSV(String columnName, String csv) booleanSupports BLOBTO_Blob(byte[] blob) Convert blob to hex encoded string and return SQL function that will convert the hex encoded string back to blobCreate SQL for formatted Date, NumberCreate SQL TO Date String from TimestampReturn string as JSON object for INSERT statementsTO_NUMBER(BigDecimal number, int displayType) Return number as string for INSERT statements with correct precisiontoString()String RepresentationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.compiere.db.AdempiereDatabase
getSQLCreate, isNativeMode, quoteColumnName
-
Field Details
-
DRIVER
Driver Class Name- See Also:
-
DEFAULT_PORT
public static final int DEFAULT_PORTDefault Port- See Also:
-
DEFAULT_CM_PORT
public static final int DEFAULT_CM_PORTDefault Connection Manager Port- See Also:
-
-
Constructor Details
-
DB_Oracle
public DB_Oracle()Oracle Database
-
-
Method Details
-
getName
Get Database Name- Specified by:
getNamein interfaceAdempiereDatabase- Returns:
- database short name
-
getDescription
Get Database Description- Specified by:
getDescriptionin interfaceAdempiereDatabase- Returns:
- database long name and version
-
getStandardPort
public int getStandardPort()Get Standard JDBC Port- Specified by:
getStandardPortin interfaceAdempiereDatabase- Returns:
- standard port
-
getDriver
Get and register Database Driver- Specified by:
getDriverin interfaceAdempiereDatabase- Returns:
- Driver
- Throws:
SQLException
-
getConnectionURL
Get Database Connection String.Timing: - CM with source_route not in address_list = 28.5 sec - CM with source_route in address_list = 58.0 sec - direct = 4.3-8 sec (no real difference if on other box) - bequeath = 3.4-8 sec
- Specified by:
getConnectionURLin interfaceAdempiereDatabase- Parameters:
connection- Connection Descriptor- Returns:
- connection String
-
getConnectionURL
Get Connection URL. http://download-east.oracle.com/docs/cd/B14117_01/java.101/b10979/urls.htm#BEIDBFDF- Specified by:
getConnectionURLin interfaceAdempiereDatabase- Parameters:
dbHost- db HostdbPort- db PortdbName- db NameuserName- user name- Returns:
- connection
-
getConnectionURL
Get Database Connection String- Specified by:
getConnectionURLin interfaceAdempiereDatabase- Parameters:
connectionURL- Connection URLuserName- user name- Returns:
- connection String
-
getCatalog
Get JDBC Catalog- Specified by:
getCatalogin interfaceAdempiereDatabase- Returns:
- null - not used
-
getSchema
Get JDBC Schema- Specified by:
getSchemain interfaceAdempiereDatabase- Returns:
- user name
-
supportsBLOB
public boolean supportsBLOB()Supports BLOB- Specified by:
supportsBLOBin interfaceAdempiereDatabase- Returns:
- true if BLOB is supported
-
toString
String Representation- Specified by:
toStringin interfaceAdempiereDatabase- Overrides:
toStringin classObject- Returns:
- info
-
getStatus
Get Status- Specified by:
getStatusin interfaceAdempiereDatabase- Returns:
- status info
-
convertStatement
Convert an individual Oracle Style statements to target database statement syntax.- Specified by:
convertStatementin interfaceAdempiereDatabase- Parameters:
oraStatement- oracle statement- Returns:
- converted Statement oracle statement
-
isSupported
Check if DBMS support the sql statement- Specified by:
isSupportedin interfaceAdempiereDatabase- Parameters:
sql- SQL statement- Returns:
- true: yes
-
getConstraintType
Get constraint type associated with the index- Specified by:
getConstraintTypein interfaceAdempiereDatabase- Parameters:
conn- connectiontableName- table nameIXName- Index name- Returns:
- String[0] = 0: do not know, 1: Primary Key 2: Foreign Key String[1] - String[n] = Constraint Name
-
getSystemUser
Get Name of System User- Specified by:
getSystemUserin interfaceAdempiereDatabase- Returns:
- system
-
getSystemDatabase
Get Name of System Database- Specified by:
getSystemDatabasein interfaceAdempiereDatabase- Parameters:
databaseName- database Name- Returns:
- e.g. master or database Name
-
TO_DATE
Create SQL TO Date String from Timestamp- Specified by:
TO_DATEin interfaceAdempiereDatabase- Parameters:
time- Date to be converteddayOnly- true if time set to 00:00:00- Returns:
- TO_DATE('2001-01-30 18:10:20',''YYYY-MM-DD HH24:MI:SS') or TO_DATE('2001-01-30',''YYYY-MM-DD')
-
TO_CHAR
Create SQL for formatted Date, Number- Specified by:
TO_CHARin interfaceAdempiereDatabase- Parameters:
columnName- the column name in the SQLdisplayType- Display TypeAD_Language- 6 character language setting (from Env.LANG_*)- Returns:
- TRIM(TO_CHAR(columnName,'999G999G999G990D00','NLS_NUMERIC_CHARACTERS='',.''')) or TRIM(TO_CHAR(columnName,'TM9')) depending on DisplayType and Language
- See Also:
-
TO_NUMBER
Return number as string for INSERT statements with correct precision- Specified by:
TO_NUMBERin interfaceAdempiereDatabase- Parameters:
number- numberdisplayType- display Type- Returns:
- number as string
-
getJSONCast
- Specified by:
getJSONCastin interfaceAdempiereDatabase- Returns:
- string with right casting for JSON inserts
-
TO_JSON
Return string as JSON object for INSERT statements- Specified by:
TO_JSONin interfaceAdempiereDatabase- Parameters:
value-- Returns:
- value as json
-
getCommands
Get SQL Commands. The following variables are resolved:- Specified by:
getCommandsin interfaceAdempiereDatabase- Parameters:
cmdType- CMD_*- Returns:
- array of commands to be executed
-
getDataSource
Description copied from interface:AdempiereDatabaseCreate DataSource- Specified by:
getDataSourcein interfaceAdempiereDatabase- Parameters:
connection- connection- Returns:
- data source
-
getCachedConnection
public Connection getCachedConnection(CConnection connection, boolean autoCommit, int transactionIsolation) throws Exception Get Cached Connection- Specified by:
getCachedConnectionin interfaceAdempiereDatabase- Parameters:
connection- connectionautoCommit- auto committransactionIsolation- trx isolation- Returns:
- Connection
- Throws:
Exception
-
getDriverConnection
Get Connection from Driver- Specified by:
getDriverConnectionin interfaceAdempiereDatabase- Parameters:
connection- info- Returns:
- connection or null
- Throws:
SQLException
-
getDriverConnection
Get Driver Connection- Specified by:
getDriverConnectionin interfaceAdempiereDatabase- Parameters:
dbUrl- URLdbUid- userdbPwd- password- Returns:
- connection
- Throws:
SQLException
-
close
public void close()Close- Specified by:
closein interfaceAdempiereDatabase
-
cleanup
public void cleanup()Clean up -
getDataType
@Deprecated public String getDataType(String columnName, int displayType, int precision, boolean defaultValue) Deprecated.Get Data Type- Parameters:
columnName-displayType- display typeprecision- precisiondefaultValue- if true adds default value- Returns:
- data type
-
getAlternativeSQL
Check and generate an alternative SQL- Specified by:
getAlternativeSQLin interfaceAdempiereDatabase- Parameters:
reExNo- number of re-executionmsg- previous execution error messagesql- previous executed SQL- Returns:
- String, the alternative SQL, null if no alternative
-
getConvert
Description copied from interface:AdempiereDatabaseGetConvertimplementation for this DB adapter- Specified by:
getConvertin interfaceAdempiereDatabase- Returns:
- Convert instance
-
getNextID
Description copied from interface:AdempiereDatabaseGet next sequence number in this Sequence- Specified by:
getNextIDin interfaceAdempiereDatabase- Parameters:
name- Sequence name
-
getNextID
Description copied from interface:AdempiereDatabaseGet next sequence number in this Sequence- Specified by:
getNextIDin interfaceAdempiereDatabase- Parameters:
name- Sequence nametrxName- Transaction name
-
createSequence
public boolean createSequence(String name, int increment, int minvalue, int maxvalue, int start, String trxName) Description copied from interface:AdempiereDatabaseCreate Native Sequence- Specified by:
createSequencein interfaceAdempiereDatabase- Parameters:
name- Sequence Name
-
isQueryTimeoutSupported
public boolean isQueryTimeoutSupported()- Specified by:
isQueryTimeoutSupportedin interfaceAdempiereDatabase- Returns:
- true if jdbc driver support statement timeout
-
addPagingSQL
Implemented using the fetch first and offset feature. use 1 base index for start and end parameter- Specified by:
addPagingSQLin interfaceAdempiereDatabase- Parameters:
sql-start-end-- Returns:
- SQL with added paging clause
-
isPagingSupported
public boolean isPagingSupported()Description copied from interface:AdempiereDatabaseIs the database have sql extension that return a subset of the query result- Specified by:
isPagingSupportedin interfaceAdempiereDatabase- Returns:
- true if DB support paging SQL
-
forUpdate
Description copied from interface:AdempiereDatabaseLock PO for update- Specified by:
forUpdatein interfaceAdempiereDatabase- Returns:
- true if lock is granted
-
getNameOfUniqueConstraintError
- Specified by:
getNameOfUniqueConstraintErrorin interfaceAdempiereDatabase- Returns:
- unique constraint name
-
getForeignKeyConstraint
Description copied from interface:AdempiereDatabaseThe "child record found error" contains the foreign key constraint name after the second occurrence of the opening double quote: ["].
Example:
ERROR: update or delete on table "m_product_category" violates foreign key constraint "mprodcategory_mdiscountsbreak" on table "m_discountschemabreak" Detail: Key (m_product_category_id)=(50000) is still referenced from table "m_discountschemabreak".
- Specified by:
getForeignKeyConstraintin interfaceAdempiereDatabase- Returns:
- constraint name
-
subsetClauseForCSV
- Specified by:
subsetClauseForCSVin interfaceAdempiereDatabasecsv- comma separated value- Returns:
- subset sql clause
-
intersectClauseForCSV
- Specified by:
intersectClauseForCSVin interfaceAdempiereDatabasecsv- comma separated value- Returns:
- intersect sql clause
-
intersectClauseForCSV
- Specified by:
intersectClauseForCSVin interfaceAdempiereDatabasecsv- comma separated value- Returns:
- intersect sql clause
-
getNumericDataType
- Specified by:
getNumericDataTypein interfaceAdempiereDatabase- Returns:
- numeric data type name
-
getCharacterDataType
- Specified by:
getCharacterDataTypein interfaceAdempiereDatabase- Returns:
- fixed length character data type name
-
getVarcharDataType
- Specified by:
getVarcharDataTypein interfaceAdempiereDatabase- Returns:
- variable length character data type name
-
getVarcharLengthSuffix
- Specified by:
getVarcharLengthSuffixin interfaceAdempiereDatabase- Returns:
- variable length character data type suffix
-
getBlobDataType
- Specified by:
getBlobDataTypein interfaceAdempiereDatabase- Returns:
- binary large object data type name
-
getClobDataType
- Specified by:
getClobDataTypein interfaceAdempiereDatabase- Returns:
- character large object data type name
-
getJsonDataType
- Specified by:
getJsonDataTypein interfaceAdempiereDatabase- Returns:
- json object data type name
-
getTimestampDataType
- Specified by:
getTimestampDataTypein interfaceAdempiereDatabase- Returns:
- time stamp data type name
-
getTimestampWithTimezoneDataType
- Specified by:
getTimestampWithTimezoneDataTypein interfaceAdempiereDatabase- Returns:
- timestamp with time zone type name
-
getUUIDDataType
- Specified by:
getUUIDDataTypein interfaceAdempiereDatabase- Returns:
- UUID type name
-
getSQLDDL
- Specified by:
getSQLDDLin interfaceAdempiereDatabase- Returns:
- DDL SQL statement for column
-
getSQLAdd
Get SQL Add command- Specified by:
getSQLAddin interfaceAdempiereDatabase- Parameters:
table- table- Returns:
- sql
-
getSQLModify
Get SQL Modify command- Specified by:
getSQLModifyin interfaceAdempiereDatabase- Parameters:
table- tablesetNullOption- generate null / not null statement- Returns:
- sql separated by ;
-
isQueryTimeout
- Specified by:
isQueryTimeoutin interfaceAdempiereDatabase- Returns:
- true if ex is caused by query timeout
-
getTablePartitionService
Description copied from interface:AdempiereDatabaseGet DB specific table partition support- Specified by:
getTablePartitionServicein interfaceAdempiereDatabase- Returns:
- ITablePartitionService instance
-
TO_Blob
Description copied from interface:AdempiereDatabaseConvert blob to hex encoded string and return SQL function that will convert the hex encoded string back to blob- Specified by:
TO_Blobin interfaceAdempiereDatabase- Returns:
- SQL statement
-