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
Modifier and TypeFieldDescriptionstatic final int
Default Connection Manager Portstatic final int
Default Portstatic final String
Driver 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
-
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 parametervoid
cleanup()
Clean upvoid
close()
CloseconvertStatement
(String oraStatement) Convert an individual Oracle Style statements to target database statement syntax.boolean
createSequence
(String name, int increment, int minvalue, int maxvalue, int start, String trxName) Create Native Sequenceboolean
Lock 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 indexGetConvert
implementation 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 Nameint
Get next sequence number in this Sequenceint
Get next sequence number in this SequenceGet JDBC SchemaGet SQL Add commandgetSQLModify
(MTable table, MColumn column, boolean setNullOption) Get SQL Modify commandint
Get 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) boolean
Is the database have sql extension that return a subset of the query resultboolean
boolean
boolean
isSupported
(String sql) Check if DBMS support the sql statementsubsetClauseForCSV
(String columnName, String csv) boolean
Supports 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, wait
Methods 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:
getName
in interfaceAdempiereDatabase
- Returns:
- database short name
-
getDescription
Get Database Description- Specified by:
getDescription
in interfaceAdempiereDatabase
- Returns:
- database long name and version
-
getStandardPort
public int getStandardPort()Get Standard JDBC Port- Specified by:
getStandardPort
in interfaceAdempiereDatabase
- Returns:
- standard port
-
getDriver
Get and register Database Driver- Specified by:
getDriver
in 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:
getConnectionURL
in 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:
getConnectionURL
in interfaceAdempiereDatabase
- Parameters:
dbHost
- db HostdbPort
- db PortdbName
- db NameuserName
- user name- Returns:
- connection
-
getConnectionURL
Get Database Connection String- Specified by:
getConnectionURL
in interfaceAdempiereDatabase
- Parameters:
connectionURL
- Connection URLuserName
- user name- Returns:
- connection String
-
getCatalog
Get JDBC Catalog- Specified by:
getCatalog
in interfaceAdempiereDatabase
- Returns:
- null - not used
-
getSchema
Get JDBC Schema- Specified by:
getSchema
in interfaceAdempiereDatabase
- Returns:
- user name
-
supportsBLOB
public boolean supportsBLOB()Supports BLOB- Specified by:
supportsBLOB
in interfaceAdempiereDatabase
- Returns:
- true if BLOB is supported
-
toString
String Representation- Specified by:
toString
in interfaceAdempiereDatabase
- Overrides:
toString
in classObject
- Returns:
- info
-
getStatus
Get Status- Specified by:
getStatus
in interfaceAdempiereDatabase
- Returns:
- status info
-
convertStatement
Convert an individual Oracle Style statements to target database statement syntax.- Specified by:
convertStatement
in interfaceAdempiereDatabase
- Parameters:
oraStatement
- oracle statement- Returns:
- converted Statement oracle statement
-
isSupported
Check if DBMS support the sql statement- Specified by:
isSupported
in interfaceAdempiereDatabase
- Parameters:
sql
- SQL statement- Returns:
- true: yes
-
getConstraintType
Get constraint type associated with the index- Specified by:
getConstraintType
in 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:
getSystemUser
in interfaceAdempiereDatabase
- Returns:
- system
-
getSystemDatabase
Get Name of System Database- Specified by:
getSystemDatabase
in interfaceAdempiereDatabase
- Parameters:
databaseName
- database Name- Returns:
- e.g. master or database Name
-
TO_DATE
Create SQL TO Date String from Timestamp- Specified by:
TO_DATE
in 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_CHAR
in 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_NUMBER
in interfaceAdempiereDatabase
- Parameters:
number
- numberdisplayType
- display Type- Returns:
- number as string
-
getJSONCast
- Specified by:
getJSONCast
in interfaceAdempiereDatabase
- Returns:
- string with right casting for JSON inserts
-
TO_JSON
Return string as JSON object for INSERT statements- Specified by:
TO_JSON
in interfaceAdempiereDatabase
- Parameters:
value
-- Returns:
- value as json
-
getCommands
Get SQL Commands. The following variables are resolved:- Specified by:
getCommands
in interfaceAdempiereDatabase
- Parameters:
cmdType
- CMD_*- Returns:
- array of commands to be executed
-
getDataSource
Description copied from interface:AdempiereDatabase
Create DataSource- Specified by:
getDataSource
in interfaceAdempiereDatabase
- Parameters:
connection
- connection- Returns:
- data source
-
getCachedConnection
public Connection getCachedConnection(CConnection connection, boolean autoCommit, int transactionIsolation) throws Exception Get Cached Connection- Specified by:
getCachedConnection
in interfaceAdempiereDatabase
- Parameters:
connection
- connectionautoCommit
- auto committransactionIsolation
- trx isolation- Returns:
- Connection
- Throws:
Exception
-
getDriverConnection
Get Connection from Driver- Specified by:
getDriverConnection
in interfaceAdempiereDatabase
- Parameters:
connection
- info- Returns:
- connection or null
- Throws:
SQLException
-
getDriverConnection
Get Driver Connection- Specified by:
getDriverConnection
in interfaceAdempiereDatabase
- Parameters:
dbUrl
- URLdbUid
- userdbPwd
- password- Returns:
- connection
- Throws:
SQLException
-
close
public void close()Close- Specified by:
close
in interfaceAdempiereDatabase
-
cleanup
public void cleanup()Clean up -
getDataType
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:
getAlternativeSQL
in 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:AdempiereDatabase
GetConvert
implementation for this DB adapter- Specified by:
getConvert
in interfaceAdempiereDatabase
- Returns:
- Convert instance
-
getNextID
Description copied from interface:AdempiereDatabase
Get next sequence number in this Sequence- Specified by:
getNextID
in interfaceAdempiereDatabase
- Parameters:
name
- Sequence name
-
getNextID
Description copied from interface:AdempiereDatabase
Get next sequence number in this Sequence- Specified by:
getNextID
in 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:AdempiereDatabase
Create Native Sequence- Specified by:
createSequence
in interfaceAdempiereDatabase
- Parameters:
name
- Sequence Name
-
isQueryTimeoutSupported
public boolean isQueryTimeoutSupported()- Specified by:
isQueryTimeoutSupported
in 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:
addPagingSQL
in interfaceAdempiereDatabase
- Parameters:
sql
-start
-end
-- Returns:
- SQL with added paging clause
-
isPagingSupported
public boolean isPagingSupported()Description copied from interface:AdempiereDatabase
Is the database have sql extension that return a subset of the query result- Specified by:
isPagingSupported
in interfaceAdempiereDatabase
- Returns:
- true if DB support paging SQL
-
forUpdate
Description copied from interface:AdempiereDatabase
Lock PO for update- Specified by:
forUpdate
in interfaceAdempiereDatabase
- Returns:
- true if lock is granted
-
getNameOfUniqueConstraintError
- Specified by:
getNameOfUniqueConstraintError
in interfaceAdempiereDatabase
- Returns:
- unique constraint name
-
getForeignKeyConstraint
Description copied from interface:AdempiereDatabase
The "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:
getForeignKeyConstraint
in interfaceAdempiereDatabase
- Returns:
- constraint name
-
subsetClauseForCSV
- Specified by:
subsetClauseForCSV
in interfaceAdempiereDatabase
csv
- comma separated value- Returns:
- subset sql clause
-
intersectClauseForCSV
- Specified by:
intersectClauseForCSV
in interfaceAdempiereDatabase
csv
- comma separated value- Returns:
- intersect sql clause
-
intersectClauseForCSV
- Specified by:
intersectClauseForCSV
in interfaceAdempiereDatabase
csv
- comma separated value- Returns:
- intersect sql clause
-
getNumericDataType
- Specified by:
getNumericDataType
in interfaceAdempiereDatabase
- Returns:
- numeric data type name
-
getCharacterDataType
- Specified by:
getCharacterDataType
in interfaceAdempiereDatabase
- Returns:
- fixed length character data type name
-
getVarcharDataType
- Specified by:
getVarcharDataType
in interfaceAdempiereDatabase
- Returns:
- variable length character data type name
-
getVarcharLengthSuffix
- Specified by:
getVarcharLengthSuffix
in interfaceAdempiereDatabase
- Returns:
- variable length character data type suffix
-
getBlobDataType
- Specified by:
getBlobDataType
in interfaceAdempiereDatabase
- Returns:
- binary large object data type name
-
getClobDataType
- Specified by:
getClobDataType
in interfaceAdempiereDatabase
- Returns:
- character large object data type name
-
getJsonDataType
- Specified by:
getJsonDataType
in interfaceAdempiereDatabase
- Returns:
- json object data type name
-
getTimestampDataType
- Specified by:
getTimestampDataType
in interfaceAdempiereDatabase
- Returns:
- time stamp data type name
-
getTimestampWithTimezoneDataType
- Specified by:
getTimestampWithTimezoneDataType
in interfaceAdempiereDatabase
- Returns:
- timestamp with time zone type name
-
getSQLDDL
- Specified by:
getSQLDDL
in interfaceAdempiereDatabase
- Returns:
- DDL SQL statement for column
-
getSQLAdd
Get SQL Add command- Specified by:
getSQLAdd
in interfaceAdempiereDatabase
- Parameters:
table
- table- Returns:
- sql
-
getSQLModify
Get SQL Modify command- Specified by:
getSQLModify
in interfaceAdempiereDatabase
- Parameters:
table
- tablesetNullOption
- generate null / not null statement- Returns:
- sql separated by ;
-
isQueryTimeout
- Specified by:
isQueryTimeout
in interfaceAdempiereDatabase
- Returns:
- true if ex is caused by query timeout
-
getTablePartitionService
Description copied from interface:AdempiereDatabase
Get DB specific table partition support- Specified by:
getTablePartitionService
in interfaceAdempiereDatabase
- Returns:
- ITablePartitionService instance
-
TO_Blob
Description copied from interface:AdempiereDatabase
Convert blob to hex encoded string and return SQL function that will convert the hex encoded string back to blob- Specified by:
TO_Blob
in interfaceAdempiereDatabase
- Returns:
- SQL statement
-