Package org.compiere.db
Interface AdempiereDatabase
- All Known Implementing Classes:
DB_Oracle
,DB_PostgreSQL
public interface AdempiereDatabase
Interface for database adapter
- Version:
- $Id: AdempiereDatabase.java,v 1.5 2006/09/22 23:35:19 jjanke Exp $
- Author:
- Jorg Janke
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Create Database/Schema Commandsstatic final int
Create User commandsstatic final int
Drop Database/Schema Commandsstatic final int
default lock timeout, 60 secondsstatic final int
-
Method Summary
Modifier and TypeMethodDescriptionaddPagingSQL
(String sql, int start, int end) modify sql to return a subset of the query result. use 1 base index for start and end parametervoid
close()
CloseconvertStatement
(String oraStatement) Convert an individual Oracle syntax statements to target database statement syntaxboolean
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 Connection on ServerGet JDBC CatalogString[]
getCommands
(int cmdType) Get SQL Commands.getConnectionURL
(String dbHost, int dbPort, String dbName, String userName) Get Connection URLgetConnectionURL
(String connectionURL, String userName) Get Database Connection URLgetConnectionURL
(CConnection connection) Get Database Connection StringgetConstraintType
(Connection conn, String tableName, String IXName) Get constraint type associated with the indexGetConvert
implementation for this DB adaptergetDataSource
(CConnection connection) Create DataSourceGet 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 Schemadefault String
getSQLCreate
(MTable table) Get create table SQL statementgetSQLModify
(MTable table, MColumn column, boolean setNullOption) int
Get Standard JDBC PortGet StatusgetSystemDatabase
(String databaseName) Get Name of System DatabaseGet Name of System Userdefault ITablePartitionService
Get DB specific table partition supportdefault String
intersectClauseForCSV
(String columnName, String csv) intersectClauseForCSV
(String columnName, String csv, boolean isNotClause) default boolean
boolean
Is the database have sql extension that return a subset of the query resultdefault boolean
boolean
boolean
isSupported
(String sql) Check if DBMS support the sql statementdefault String
quoteColumnName
(String columnName) Quote column name if necessary (usually to avoid conflict with reserved keywords)subsetClauseForCSV
(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 statement for TimestampReturn string as JSON object for INSERT statementsTO_NUMBER
(BigDecimal number, int displayType) Return number as string for INSERT statements with correct precisiontoString()
String Representation
-
Field Details
-
LOCK_TIME_OUT
static final int LOCK_TIME_OUTdefault lock timeout, 60 seconds- See Also:
-
MAX_OBJECT_NAME_LENGTH
static final int MAX_OBJECT_NAME_LENGTH- See Also:
-
CMD_CREATE_USER
static final int CMD_CREATE_USERCreate User commands- See Also:
-
CMD_CREATE_DATABASE
static final int CMD_CREATE_DATABASECreate Database/Schema Commands- See Also:
-
CMD_DROP_DATABASE
static final int CMD_DROP_DATABASEDrop Database/Schema Commands- See Also:
-
-
Method Details
-
getName
String getName()Get Database Name- Returns:
- database short name
-
getDescription
String getDescription()Get Database Description- Returns:
- database long name and version
-
getDriver
Get and register Database Driver- Returns:
- Driver
- Throws:
SQLException
-
getStandardPort
int getStandardPort()Get Standard JDBC Port- Returns:
- standard port
-
getConnectionURL
Get Database Connection String- Parameters:
connection
- Connection Descriptor- Returns:
- connection String
-
getConnectionURL
Get Connection URL- Parameters:
dbHost
- db HostdbPort
- db PortdbName
- db NameuserName
- user name- Returns:
- url
-
getConnectionURL
Get Database Connection URL- Parameters:
connectionURL
- Connection URLuserName
- user name- Returns:
- connection URL
-
getCatalog
String getCatalog()Get JDBC Catalog- Returns:
- catalog
-
getSchema
String getSchema()Get JDBC Schema- Returns:
- schema
-
supportsBLOB
boolean supportsBLOB()Supports BLOB- Returns:
- true if BLOB is supported
-
toString
String toString()String Representation -
convertStatement
Convert an individual Oracle syntax statements to target database statement syntax- Parameters:
oraStatement
- oracle statement- Returns:
- converted Statement
-
isSupported
Check if DBMS support the sql statement- Parameters:
sql
- SQL statement- Returns:
- true: yes
-
getConstraintType
Get constraint type associated with the index- 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
-
getAlternativeSQL
Check and generate an alternative SQL- Parameters:
reExNo
- number of re-executionmsg
- previous execution error messagesql
- previous executed SQL- Returns:
- String, the alternative SQL, null if no alternative
-
getSystemUser
String getSystemUser()Get Name of System User- Returns:
- e.g. sa, system
-
getSystemDatabase
Get Name of System Database- Parameters:
databaseName
- database Name- Returns:
- e.g. master or database Name
-
TO_DATE
Create SQL TO Date statement for Timestamp- Parameters:
time
- Date to be converteddayOnly
- true if time should be set to 00:00:00- Returns:
- to date function
-
TO_CHAR
Create SQL for formatted Date, Number- 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- Parameters:
number
- numberdisplayType
- display Type- Returns:
- number as string
-
TO_JSON
Return string as JSON object for INSERT statements- Parameters:
value
-- Returns:
- value as JSON
-
getJSONCast
String getJSONCast()- Returns:
- string with right casting for JSON inserts
-
getNextID
Get next sequence number in this Sequence- Parameters:
Name
- Sequence nametrxName
- Transaction name
-
getNextID
Get next sequence number in this Sequence- Parameters:
Name
- Sequence name
-
createSequence
boolean createSequence(String name, int increment, int minvalue, int maxvalue, int start, String trxName) Create Native Sequence- Parameters:
name
- Sequence Nameincrement
-minvalue
-maxvalue
-start
-trxName
-
-
getCommands
Get SQL Commands.The following variables are resolved:
- Parameters:
cmdType
-CMD_CREATE_USER
,CMD_CREATE_DATABASE
orCMD_DROP_DATABASE
- Returns:
- array of commands to be executed
-
getCachedConnection
Connection getCachedConnection(CConnection connection, boolean autoCommit, int transactionIsolation) throws Exception Get Cached Connection on Server- Parameters:
connection
- infoautoCommit
- true if autocommit connectiontransactionIsolation
- transaction isolation level- Returns:
- connection or null
- Throws:
Exception
-
getDriverConnection
Get Connection from Driver- Parameters:
connection
- info- Returns:
- connection or null
- Throws:
SQLException
-
getDriverConnection
Get Driver Connection- Parameters:
dbUrl
- URLdbUid
- userdbPwd
- password- Returns:
- connection
- Throws:
SQLException
-
getDataSource
Create DataSource- Parameters:
connection
- connection- Returns:
- data source
-
getStatus
String getStatus()Get Status- Returns:
- status info or null if no local datasource available
-
close
void close()Close -
getConvert
Convert getConvert()GetConvert
implementation for this DB adapter- Returns:
- Convert instance
-
isQueryTimeoutSupported
boolean isQueryTimeoutSupported()- Returns:
- true if jdbc driver support statement timeout
-
isPagingSupported
boolean isPagingSupported()Is the database have sql extension that return a subset of the query result- Returns:
- true if DB support paging SQL
-
addPagingSQL
modify sql to return a subset of the query result. use 1 base index for start and end parameter- Parameters:
sql
-start
-end
-- Returns:
- SQL with added paging clause
-
forUpdate
Lock PO for update- Parameters:
po
-timeout
-- Returns:
- true if lock is granted
-
getNameOfUniqueConstraintError
- Parameters:
e
-- Returns:
- unique constraint name
-
getForeignKeyConstraint
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".
- Parameters:
e
-- Returns:
- constraint name
-
subsetClauseForCSV
- Parameters:
columnName
-csv
- comma separated value- Returns:
- subset sql clause
-
intersectClauseForCSV
- Parameters:
columnName
-csv
- comma separated value- Returns:
- intersect sql clause
-
intersectClauseForCSV
- Parameters:
columnName
-csv
- comma separated valueisNotClause
-- Returns:
- intersect sql clause
-
quoteColumnName
Quote column name if necessary (usually to avoid conflict with reserved keywords)- Parameters:
columnName
-- Returns:
- columnName or quoted columnName
-
isNativeMode
default boolean isNativeMode()- Returns:
- true if using native dialect, false if using oracle dialect
-
getNumericDataType
String getNumericDataType()- Returns:
- numeric data type name
-
getCharacterDataType
String getCharacterDataType()- Returns:
- fixed length character data type name
-
getVarcharDataType
String getVarcharDataType()- Returns:
- variable length character data type name
-
getVarcharLengthSuffix
- Returns:
- variable length character data type suffix
-
getBlobDataType
String getBlobDataType()- Returns:
- binary large object data type name
-
getClobDataType
String getClobDataType()- Returns:
- character large object data type name
-
getJsonDataType
String getJsonDataType()- Returns:
- json object data type name
-
getTimestampDataType
String getTimestampDataType()- Returns:
- time stamp data type name
-
getTimestampWithTimezoneDataType
String getTimestampWithTimezoneDataType()- Returns:
- timestamp with time zone type name
-
getSQLCreate
Get create table SQL statement- Parameters:
table
-- Returns:
- create table DDL
-
TO_Blob
Convert blob to hex encoded string and return SQL function that will convert the hex encoded string back to blob- Parameters:
blob
-- Returns:
- SQL statement
-
getSQLDDL
- Parameters:
column
-- Returns:
- DDL SQL statement for column
-
getSQLAdd
- Parameters:
table
-column
-- Returns:
- add column SQL statement
-
getSQLModify
- Parameters:
table
-column
-setNullOption
-- Returns:
- alter column SQL statement
-
isQueryTimeout
- Parameters:
ex
-- Returns:
- true if ex is caused by query timeout
-
getTablePartitionService
Get DB specific table partition support- Returns:
- ITablePartitionService instance
-