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
Modifier and TypeFieldDescriptionstatic final int
Default Portstatic final String
Driver classstatic final String
Fields 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
close()
CloseconvertStatement
(String oraStatement) Convert an individual Oracle Style statements to target database statement syntaxcreatePoolDataSource
(CConnection connection) Create Pooled DataSource (Server)boolean
createSequence
(String name, int increment, int minvalue, int maxvalue, int start, String trxName) Create Native Sequencestatic void
dumpLocks
(Connection conn) Dump table lock info to console for current transactionboolean
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 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 indexGetConvert
implementation 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«int
Get next sequence number in this Sequenceint
Get next sequence number in this SequenceGet RowSetGet 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
boolean
Is the database have sql extension that return a subset of the query resultboolean
boolean
Postgresql jdbc driver doesn't support setQueryTimeout, query/statement timeout is implemented using the "SET LOCAL statement_timeout TO" statement.boolean
isSupported
(String sql) Check if DBMS support the sql statementstatic final boolean
static final String
markNativeKeyword
(String keyword) quoteColumnName
(String columnName) Quote column name if necessary (usually to avoid conflict with reserved keywords)static final String
removeNativeKeyworkMarker
(String statement) 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 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, 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:AdempiereDatabase
GetConvert
implementation for this DB adapter- Specified by:
getConvert
in interfaceAdempiereDatabase
- Returns:
- Convert instance
-
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. Requirements: - createdb -E UNICODE compiere- Specified by:
getConnectionURL
in interfaceAdempiereDatabase
- Parameters:
connection
- Connection Descriptor- Returns:
- connection String
-
getConnectionURL
Get Connection URL- Specified by:
getConnectionURL
in interfaceAdempiereDatabase
- Parameters:
dbHost
- db HostdbPort
- db PortdbName
- sb NameuserName
- user name- Returns:
- connection url
-
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:
- catalog (database name)
-
getSchema
Get JDBC Schema- Specified by:
getSchema
in interfaceAdempiereDatabase
- Returns:
- schema (dbo)
-
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
-- Returns:
- converted Statement
- Throws:
Exception
-
getSystemUser
Get Name of System User- Specified by:
getSystemUser
in interfaceAdempiereDatabase
- Returns:
- e.g. sa, 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_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_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- Specified by:
getCommands
in 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:
getCachedConnection
in interfaceAdempiereDatabase
- Parameters:
connection
- connectionautoCommit
- auto committransactionIsolation
- trx isolation- Returns:
- Connection
- Throws:
Exception
-
getDataSource
Create DataSource (Client)- Specified by:
getDataSource
in 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:
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
-
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
-
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
-
isSupported
Check if DBMS support the sql statement- Specified by:
isSupported
in 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: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()Postgresql jdbc driver doesn't support setQueryTimeout, query/statement timeout is implemented using the "SET LOCAL statement_timeout TO" statement.- Specified by:
isQueryTimeoutSupported
in interfaceAdempiereDatabase
- Returns:
- true
-
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
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:
getNameOfUniqueConstraintError
in 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:
getForeignKeyConstraint
in interfaceAdempiereDatabase
- Returns:
- constraint name
-
subsetClauseForCSV
- Specified by:
subsetClauseForCSV
in interfaceAdempiereDatabase
csv
- comma separated value- Returns:
- subset sql clause
-
quoteColumnName
Description copied from interface:AdempiereDatabase
Quote column name if necessary (usually to avoid conflict with reserved keywords)- Specified by:
quoteColumnName
in interfaceAdempiereDatabase
- Returns:
- columnName or quoted columnName
-
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
-
isNativeMode
public boolean isNativeMode()- Specified by:
isNativeMode
in 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:
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
-
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
-