Package org.compiere.db
Interface AdempiereDatabase
-
- All Known Implementing Classes:
DB_Oracle
,DB_PostgreSQL
public interface AdempiereDatabase
Interface for Adempiere Databases- Version:
- $Id: AdempiereDatabase.java,v 1.5 2006/09/22 23:35:19 jjanke Exp $
- Author:
- Jorg Janke
-
-
Field Summary
Fields Modifier and Type Field Description static int
CMD_CREATE_DATABASE
Create Database/Schema Commandsstatic int
CMD_CREATE_USER
Create User commandsstatic int
CMD_DROP_DATABASE
Drop Database/Schema Commandsstatic int
LOCK_TIME_OUT
default lock timeout, 60 seconds
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
addPagingSQL(String sql, int start, int end)
modify sql to return a subset of the query resultvoid
close()
CloseString
convertStatement(String oraStatement)
Convert an individual Oracle Style statements to target database statement syntaxboolean
createSequence(String name, int increment, int minvalue, int maxvalue, int start, String trxName)
boolean
forUpdate(PO po, int timeout)
Lock PO for updateString
getAlternativeSQL(int reExNo, String msg, String sql)
Check and generate an alternative SQLString
getBlobDataType()
Connection
getCachedConnection(CConnection connection, boolean autoCommit, int transactionIsolation)
Get Cached Connection on ServerString
getCatalog()
Get JDBC CatalogString
getCharacterDataType()
String
getClobDataType()
String[]
getCommands(int cmdType)
Get SQL Commands.String
getConnectionURL(String dbHost, int dbPort, String dbName, String userName)
Get Connection URLString
getConnectionURL(String connectionURL, String userName)
Get Database Connection StringString
getConnectionURL(CConnection connection)
Get Database Connection StringString
getConstraintType(Connection conn, String tableName, String IXName)
Get constraint type associated with the indexConvert
getConvert()
DataSource
getDataSource(CConnection connection)
Create DataSourceString
getDescription()
Get Database DescriptionDriver
getDriver()
Get and register Database DriverConnection
getDriverConnection(String dbUrl, String dbUid, String dbPwd)
Get Driver ConnectionConnection
getDriverConnection(CConnection connection)
Get Connection from DriverString
getName()
Get Database NameString
getNameOfUniqueConstraintError(Exception e)
int
getNextID(String Name)
Return next sequence this Sequenceint
getNextID(String Name, String trxName)
Return next sequence this SequenceString
getNumericDataType()
String
getSchema()
Get JDBC SchemaString
getSQLAdd(MTable table, MColumn column)
default String
getSQLCreate(MTable table)
Get SQL CreateString
getSQLDDL(MColumn column)
String
getSQLModify(MTable table, MColumn column, boolean setNullOption)
int
getStandardPort()
Get Standard JDBC PortString
getStatus()
Get StatusString
getSystemDatabase(String databaseName)
Get Name of System DatabaseString
getSystemUser()
Get Name of System UserString
getTimestampDataType()
String
getVarcharDataType()
default String
getVarcharLengthSuffix()
String
intersectClauseForCSV(String columnName, String csv)
default boolean
isNativeMode()
boolean
isPagingSupported()
Is the database have sql extension that return a subset of the query resultdefault boolean
isQueryTimeout(SQLException ex)
boolean
isQueryTimeoutSupported()
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)String
subsetClauseForCSV(String columnName, String csv)
boolean
supportsBLOB()
Supports BLOBString
TO_CHAR(String columnName, int displayType, String AD_Language)
Create SQL for formatted Date, NumberString
TO_DATE(Timestamp time, boolean dayOnly)
Create SQL TO Date String from TimestampString
TO_NUMBER(BigDecimal number, int displayType)
Return number as string for INSERT statements with correct precisionString
toString()
String Representation
-
-
-
Field Detail
-
LOCK_TIME_OUT
static final int LOCK_TIME_OUT
default lock timeout, 60 seconds- See Also:
- Constant Field Values
-
CMD_CREATE_USER
static final int CMD_CREATE_USER
Create User commands- See Also:
- Constant Field Values
-
CMD_CREATE_DATABASE
static final int CMD_CREATE_DATABASE
Create Database/Schema Commands- See Also:
- Constant Field Values
-
CMD_DROP_DATABASE
static final int CMD_DROP_DATABASE
Drop Database/Schema Commands- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
String getName()
Get Database Name- Returns:
- database short name
-
getDescription
String getDescription()
Get Database Description- Returns:
- database long name and version
-
getDriver
Driver getDriver() throws SQLException
Get and register Database Driver- Returns:
- Driver
- Throws:
SQLException
-
getStandardPort
int getStandardPort()
Get Standard JDBC Port- Returns:
- standard port
-
getConnectionURL
String getConnectionURL(CConnection connection)
Get Database Connection String- Parameters:
connection
- Connection Descriptor- Returns:
- connection String
-
getConnectionURL
String getConnectionURL(String dbHost, int dbPort, String dbName, String userName)
Get Connection URL- Parameters:
dbHost
- db HostdbPort
- db PortdbName
- db NameuserName
- user name- Returns:
- url
-
getConnectionURL
String getConnectionURL(String connectionURL, String userName)
Get Database Connection String- Parameters:
connectionURL
- Connection URLuserName
- user name- Returns:
- connection String
-
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
-
convertStatement
String convertStatement(String oraStatement)
Convert an individual Oracle Style statements to target database statement syntax- Parameters:
oraStatement
- oracle statement- Returns:
- converted Statement
-
isSupported
boolean isSupported(String sql)
Check if DBMS support the sql statement- Returns:
- true: yes
-
getConstraintType
String getConstraintType(Connection conn, String tableName, String IXName)
Get constraint type associated with the index- Returns:
- String[0] = 0: do not know, 1: Primary Key 2: Foreign Key String[1] - String[n] = Constraint Name
-
getAlternativeSQL
String getAlternativeSQL(int reExNo, String msg, String sql)
Check and generate an alternative SQL- Returns:
- String, the alternative SQL, null if no alternative
-
getSystemUser
String getSystemUser()
Get Name of System User- Returns:
- e.g. sa, system
-
getSystemDatabase
String getSystemDatabase(String databaseName)
Get Name of System Database- Parameters:
databaseName
- database Name- Returns:
- e.g. master or database Name
-
TO_DATE
String TO_DATE(Timestamp time, boolean dayOnly)
Create SQL TO Date String from Timestamp- Parameters:
time
- Date to be converteddayOnly
- true if time set to 00:00:00- Returns:
- date function
-
TO_CHAR
String TO_CHAR(String columnName, int displayType, String AD_Language)
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:
DisplayType
,Env
-
TO_NUMBER
String TO_NUMBER(BigDecimal number, int displayType)
Return number as string for INSERT statements with correct precision- Parameters:
number
- numberdisplayType
- display Type- Returns:
- number as string
-
getNextID
int getNextID(String Name, String trxName)
Return next sequence this Sequence- Parameters:
Name
- SequencetrxName
- Transaction
-
getNextID
int getNextID(String Name)
Return next sequence this Sequence- Parameters:
Name
- Sequence
-
createSequence
boolean createSequence(String name, int increment, int minvalue, int maxvalue, int start, String trxName)
-
getCommands
String[] getCommands(int cmdType)
Get SQL Commands.The following variables are resolved:
- Parameters:
cmdType
- CMD_*- 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
- Connection transaction level- Returns:
- connection or null
- Throws:
Exception
-
getDriverConnection
Connection getDriverConnection(CConnection connection) throws SQLException
Get Connection from Driver- Parameters:
connection
- info- Returns:
- connection or null
- Throws:
SQLException
-
getDriverConnection
Connection getDriverConnection(String dbUrl, String dbUid, String dbPwd) throws SQLException
Get Driver Connection- Parameters:
dbUrl
- URLdbUid
- userdbPwd
- password- Returns:
- connection
- Throws:
SQLException
-
getDataSource
DataSource getDataSource(CConnection connection)
Create DataSource- Parameters:
connection
- connection- Returns:
- data dource
-
getStatus
String getStatus()
Get Status- Returns:
- status info or null if no local datasource available
-
close
void close()
Close
-
getConvert
Convert getConvert()
-
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:
- boolean
-
addPagingSQL
String addPagingSQL(String sql, int start, int end)
modify sql to return a subset of the query result- Parameters:
sql
-start
-end
-- Returns:
-
forUpdate
boolean forUpdate(PO po, int timeout)
Lock PO for update- Parameters:
po
-timeout
-- Returns:
- true if lock is granted
-
subsetClauseForCSV
String subsetClauseForCSV(String columnName, String csv)
- Parameters:
columnName
-csv
- comma separated value- Returns:
- subset sql clause
-
intersectClauseForCSV
String intersectClauseForCSV(String columnName, String csv)
- Parameters:
columnName
-csv
- comma separated value- Returns:
- subset sql clause
-
quoteColumnName
default String quoteColumnName(String columnName)
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 lenght character data type name
-
getVarcharDataType
String getVarcharDataType()
- Returns:
- variable length character data type name
-
getVarcharLengthSuffix
default String 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
-
getTimestampDataType
String getTimestampDataType()
- Returns:
- time stamp data type name
-
getSQLCreate
default String getSQLCreate(MTable table)
Get SQL Create- Parameters:
table
-- Returns:
- create table DDL
-
getSQLAdd
String getSQLAdd(MTable table, MColumn column)
- Parameters:
table
-column
-- Returns:
- add column sql
-
getSQLModify
String getSQLModify(MTable table, MColumn column, boolean setNullOption)
- Parameters:
table
-column
-setNullOption
-- Returns:
- alter column sql
-
isQueryTimeout
default boolean isQueryTimeout(SQLException ex)
- Parameters:
ex
-- Returns:
- true if ex is caused by query timeout
-
-