Package org.compiere.db
Class DB_PostgreSQL
java.lang.Object
org.compiere.db.DB_PostgreSQL
- All Implemented Interfaces:
AdempiereDatabase
PostgreSQL Database Port
- Version:
- $Id: DB_PostgreSQL.java,v 1.23 2005/03/11 20:29:01 jjanke Exp $ --- Modifications: removed static references to database connection and instead always get a new connection from database pool manager which manages all connections set rw/ro properties for the connection accordingly.
- Author:
- , Jorg Janke, Victor Perez, Ashley Ramdass (Posterita)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault Portstatic final StringDriver classstatic final StringFields 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 parametervoidclose()CloseconvertStatement(String oraStatement) Convert an individual Oracle Style statements to target database statement syntaxcreatePoolDataSource(CConnection connection) Create Pooled DataSource (Server)booleancreateSequence(String name, int increment, int minvalue, int maxvalue, int start, String trxName) Create Native Sequencestatic voiddumpLocks(Connection conn) Dump table lock info to console for current transactionbooleanLock 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 CommandsgetConnectionURL(String dbHost, int dbPort, String dbName, String userName) Get Connection URLgetConnectionURL(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 DataSource (Client)Get Database DescriptionGet and register Database DrivergetDriverConnection(String dbUrl, String dbUid, String dbPwd) Get Driver ConnectiongetDriverConnection(CConnection connection) Get Connection from DriverGet the foreign key constraint name based on a postgresql message This method works for English, Spanish and German The foreign key constraint name is expected to be found in the second quoted string English quotes -> "constraint" Spanish quotes -> «constraint» German quotes -> »constraint«getName()Get Database NameGet the name of the unique constraint name based on a postgresql message This method works for English, Spanish and German The foreign key constraint name is expected to be found in the second quoted string English quotes -> "constraint" Spanish quotes -> «constraint» German quotes -> »constraint«intGet next sequence number in this SequenceintGet next sequence number in this SequenceGet RowSetGet 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) booleanbooleanIs the database have sql extension that return a subset of the query resultbooleanbooleanPostgresql jdbc driver doesn't support setQueryTimeout, query/statement timeout is implemented using the "SET LOCAL statement_timeout TO" statement.booleanisSupported(String sql) Check if DBMS support the sql statementstatic final booleanstatic final StringmarkNativeKeyword(String keyword) quoteColumnName(String columnName) Quote column name if necessary (usually to avoid conflict with reserved keywords)static final StringremoveNativeKeyworkMarker(String statement) subsetClauseForCSV(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, getVarcharLengthSuffix
-
Field Details
-
DRIVER
Driver class- See Also:
-
DEFAULT_PORT
public static final int DEFAULT_PORTDefault Port- See Also:
-
NATIVE_MARKER
-
-
Constructor Details
-
DB_PostgreSQL
public DB_PostgreSQL()PostgreSQL Database
-
-
Method Details
-
getConvert
Description copied from interface:AdempiereDatabaseGetConvertimplementation for this DB adapter- Specified by:
getConvertin interfaceAdempiereDatabase- Returns:
- Convert instance
-
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. Requirements: - createdb -E UNICODE compiere- Specified by:
getConnectionURLin interfaceAdempiereDatabase- Parameters:
connection- Connection Descriptor- Returns:
- connection String
-
getConnectionURL
Get Connection URL- Specified by:
getConnectionURLin interfaceAdempiereDatabase- Parameters:
dbHost- db HostdbPort- db PortdbName- sb NameuserName- user name- Returns:
- connection url
-
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:
- catalog (database name)
-
getSchema
Get JDBC Schema- Specified by:
getSchemain interfaceAdempiereDatabase- Returns:
- schema (dbo)
-
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-- Returns:
- converted Statement
- Throws:
Exception
-
getSystemUser
Get Name of System User- Specified by:
getSystemUserin interfaceAdempiereDatabase- Returns:
- e.g. sa, 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_TIMESTAMP('2001-01-30 18:10:20',''YYYY-MM-DD HH24:MI:SS') or TO_TIMESTAMP('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- Specified by:
getCommandsin interfaceAdempiereDatabase- Parameters:
cmdType- CMD_*- Returns:
- array of commands to be executed
-
getRowSet
Get RowSet- Parameters:
rs- ResultSet- Returns:
- RowSet
- Throws:
SQLException
-
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
-
getDataSource
Create DataSource (Client)- Specified by:
getDataSourcein interfaceAdempiereDatabase- Parameters:
connection- connection- Returns:
- data dource
-
createPoolDataSource
Create Pooled DataSource (Server)- Parameters:
connection- connection- Returns:
- data source
-
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
-
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
-
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
-
isSupported
Check if DBMS support the sql statement- Specified by:
isSupportedin interfaceAdempiereDatabase- Parameters:
sql- SQL statement- Returns:
- true: yes
-
dumpLocks
Dump table lock info to console for current transaction- Parameters:
conn-
-
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()Postgresql jdbc driver doesn't support setQueryTimeout, query/statement timeout is implemented using the "SET LOCAL statement_timeout TO" statement.- Specified by:
isQueryTimeoutSupportedin interfaceAdempiereDatabase- Returns:
- true
-
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
Get the name of the unique constraint name based on a postgresql message This method works for English, Spanish and German The foreign key constraint name is expected to be found in the second quoted string English quotes -> "constraint" Spanish quotes -> «constraint» German quotes -> »constraint«- Specified by:
getNameOfUniqueConstraintErrorin interfaceAdempiereDatabase- Returns:
- unique constraint name
-
getForeignKeyConstraint
Get the foreign key constraint name based on a postgresql message This method works for English, Spanish and German The foreign key constraint name is expected to be found in the second quoted string English quotes -> "constraint" Spanish quotes -> «constraint» German quotes -> »constraint«- Specified by:
getForeignKeyConstraintin interfaceAdempiereDatabase- Returns:
- constraint name
-
subsetClauseForCSV
- Specified by:
subsetClauseForCSVin interfaceAdempiereDatabasecsv- comma separated value- Returns:
- subset sql clause
-
quoteColumnName
Description copied from interface:AdempiereDatabaseQuote column name if necessary (usually to avoid conflict with reserved keywords)- Specified by:
quoteColumnNamein interfaceAdempiereDatabase- Returns:
- columnName or quoted columnName
-
intersectClauseForCSV
- Specified by:
intersectClauseForCSVin interfaceAdempiereDatabasecsv- comma separated value- Returns:
- intersect sql clause
-
intersectClauseForCSV
- Specified by:
intersectClauseForCSVin interfaceAdempiereDatabasecsv- comma separated value- Returns:
- intersect sql clause
-
isNativeMode
public boolean isNativeMode()- Specified by:
isNativeModein interfaceAdempiereDatabase- Returns:
- true if using native dialect, false if using oracle dialect
-
isUseNativeDialect
public static final boolean isUseNativeDialect()- Returns:
- true if it is using native dialect
-
markNativeKeyword
- Parameters:
keyword-- Returns:
- if not using native dialect, return native_marker + keyword
-
removeNativeKeyworkMarker
- Parameters:
statement-- Returns:
- statement after the removal of native keyword marker
-
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
-
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
-