Adempiere 3.5.2a

org.compiere.db
Class DB_PostgreSQL

java.lang.Object
  extended by org.compiere.db.DB_PostgreSQL
All Implemented Interfaces:
AdempiereDatabase

public class DB_PostgreSQL
extends Object
implements 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:
@author Jorg Janke, Victor P�rez, Ashley Ramdass (Posterita)

Field Summary
static int DEFAULT_PORT
          Default Port
static String DRIVER
          Driver class
 
Fields inherited from interface org.compiere.db.AdempiereDatabase
CMD_CREATE_DATABASE, CMD_CREATE_USER, CMD_DROP_DATABASE, DEFAULT_CONN_TEST_SQL
 
Constructor Summary
DB_PostgreSQL()
          PostgreSQL Database
 
Method Summary
 void close()
          Close
 String convertStatement(String oraStatement)
          Convert an individual Oracle Style statements to target database statement syntax
 ConnectionPoolDataSource createPoolDataSource(CConnection connection)
          Create Pooled DataSource (Server)
static void dumpLocks(Connection conn)
          Dump table lock info to console for current transaction
 String getAlternativeSQL(int reExNo, String msg, String sql)
          Check and generate an alternative SQL
 Connection getCachedConnection(CConnection connection, boolean autoCommit, int transactionIsolation)
          Get Cached Connection
 String getCatalog()
          Get JDBC Catalog
 String[] getCommands(int cmdType)
          Get SQL Commands
 String getConnectionURL(CConnection connection)
          Get Database Connection String.
 String getConnectionURL(String dbHost, int dbPort, String dbName, String userName)
          Get Connection URL
 String getConnectionURL(String connectionURL, String userName)
          Get Database Connection String
 String getConstraintType(Connection conn, String tableName, String IXName)
          Get constraint type associated with the index
 Convert getConvert()
           
 DataSource getDataSource(CConnection connection)
          Create DataSource (Client)
 String getDescription()
          Get Database Description
 Driver getDriver()
          Get and register Database Driver
 Connection getDriverConnection(CConnection connection)
          Get Connection from Driver
 Connection getDriverConnection(String dbUrl, String dbUid, String dbPwd)
          Get Driver Connection
 String getName()
          Get Database Name
 RowSet getRowSet(ResultSet rs)
          Get RowSet
 String getSchema()
          Get JDBC Schema
 int getStandardPort()
          Get Standard JDBC Port
 String getStatus()
          Get Status
 String getSystemDatabase(String databaseName)
          Get Name of System Database
 String getSystemUser()
          Get Name of System User
 boolean isSupported(String sql)
          Check if DBMS support the sql statement
static void main(String[] args)
          Test
 boolean supportsBLOB()
          Supports BLOB
 String TO_CHAR(String columnName, int displayType, String AD_Language)
          Create SQL for formatted Date, Number
 String TO_DATE(Timestamp time, boolean dayOnly)
          Create SQL TO Date String from Timestamp
 String TO_NUMBER(BigDecimal number, int displayType)
          Return number as string for INSERT statements with correct precision
 String toString()
          String Representation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DRIVER

public static final String DRIVER
Driver class

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
Default Port

See Also:
Constant Field Values
Constructor Detail

DB_PostgreSQL

public DB_PostgreSQL()
PostgreSQL Database

Method Detail

getConvert

public Convert getConvert()
Specified by:
getConvert in interface AdempiereDatabase

getName

public String getName()
Get Database Name

Specified by:
getName in interface AdempiereDatabase
Returns:
database short name

getDescription

public String getDescription()
Get Database Description

Specified by:
getDescription in interface AdempiereDatabase
Returns:
database long name and version

getStandardPort

public int getStandardPort()
Get Standard JDBC Port

Specified by:
getStandardPort in interface AdempiereDatabase
Returns:
standard port

getDriver

public Driver getDriver()
                 throws SQLException
Get and register Database Driver

Specified by:
getDriver in interface AdempiereDatabase
Returns:
Driver
Throws:
SQLException

getConnectionURL

public String getConnectionURL(CConnection connection)
Get Database Connection String. Requirements: - createdb -E UNICODE compiere

Specified by:
getConnectionURL in interface AdempiereDatabase
Parameters:
connection - Connection Descriptor
Returns:
connection String

getConnectionURL

public String getConnectionURL(String dbHost,
                               int dbPort,
                               String dbName,
                               String userName)
Get Connection URL

Specified by:
getConnectionURL in interface AdempiereDatabase
Parameters:
dbHost - db Host
dbPort - db Port
dbName - sb Name
userName - user name
Returns:
connection url

getConnectionURL

public String getConnectionURL(String connectionURL,
                               String userName)
Get Database Connection String

Specified by:
getConnectionURL in interface AdempiereDatabase
Parameters:
connectionURL - Connection URL
userName - user name
Returns:
connection String

getCatalog

public String getCatalog()
Get JDBC Catalog

Specified by:
getCatalog in interface AdempiereDatabase
Returns:
catalog (database name)

getSchema

public String getSchema()
Get JDBC Schema

Specified by:
getSchema in interface AdempiereDatabase
Returns:
schema (dbo)

supportsBLOB

public boolean supportsBLOB()
Supports BLOB

Specified by:
supportsBLOB in interface AdempiereDatabase
Returns:
true if BLOB is supported

toString

public String toString()
String Representation

Specified by:
toString in interface AdempiereDatabase
Overrides:
toString in class Object
Returns:
info

getStatus

public String getStatus()
Get Status

Specified by:
getStatus in interface AdempiereDatabase
Returns:
status info

convertStatement

public String convertStatement(String oraStatement)
Convert an individual Oracle Style statements to target database statement syntax

Specified by:
convertStatement in interface AdempiereDatabase
Parameters:
oraStatement -
Returns:
converted Statement
Throws:
Exception

getSystemUser

public String getSystemUser()
Get Name of System User

Specified by:
getSystemUser in interface AdempiereDatabase
Returns:
e.g. sa, system

getSystemDatabase

public String getSystemDatabase(String databaseName)
Get Name of System Database

Specified by:
getSystemDatabase in interface AdempiereDatabase
Parameters:
databaseName - database Name
Returns:
e.g. master or database Name

TO_DATE

public String TO_DATE(Timestamp time,
                      boolean dayOnly)
Create SQL TO Date String from Timestamp

Specified by:
TO_DATE in interface AdempiereDatabase
Parameters:
time - Date to be converted
dayOnly - 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

public String TO_CHAR(String columnName,
                      int displayType,
                      String AD_Language)
Create SQL for formatted Date, Number

Specified by:
TO_CHAR in interface AdempiereDatabase
Parameters:
columnName - the column name in the SQL
displayType - Display Type
AD_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

public String TO_NUMBER(BigDecimal number,
                        int displayType)
Return number as string for INSERT statements with correct precision

Specified by:
TO_NUMBER in interface AdempiereDatabase
Parameters:
number - number
displayType - display Type
Returns:
number as string

getCommands

public String[] getCommands(int cmdType)
Get SQL Commands

Specified by:
getCommands in interface AdempiereDatabase
Parameters:
cmdType - CMD_*
Returns:
array of commands to be executed

getRowSet

public RowSet getRowSet(ResultSet rs)
                 throws SQLException
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 interface AdempiereDatabase
Parameters:
connection - connection
autoCommit - auto commit
transactionIsolation - trx isolation
Returns:
Connection
Throws:
Exception

getDataSource

public DataSource getDataSource(CConnection connection)
Create DataSource (Client)

Specified by:
getDataSource in interface AdempiereDatabase
Parameters:
connection - connection
Returns:
data dource

createPoolDataSource

public ConnectionPoolDataSource createPoolDataSource(CConnection connection)
Create Pooled DataSource (Server)

Parameters:
connection - connection
Returns:
data dource

getDriverConnection

public Connection getDriverConnection(CConnection connection)
                               throws SQLException
Get Connection from Driver

Specified by:
getDriverConnection in interface AdempiereDatabase
Parameters:
connection - info
Returns:
connection or null
Throws:
SQLException

getDriverConnection

public Connection getDriverConnection(String dbUrl,
                                      String dbUid,
                                      String dbPwd)
                               throws SQLException
Get Driver Connection

Specified by:
getDriverConnection in interface AdempiereDatabase
Parameters:
dbUrl - URL
dbUid - user
dbPwd - password
Returns:
connection
Throws:
SQLException

close

public void close()
Close

Specified by:
close in interface AdempiereDatabase

getAlternativeSQL

public String getAlternativeSQL(int reExNo,
                                String msg,
                                String sql)
Check and generate an alternative SQL

Specified by:
getAlternativeSQL in interface AdempiereDatabase
Returns:
String, the alternative SQL, null if no alternative

getConstraintType

public String getConstraintType(Connection conn,
                                String tableName,
                                String IXName)
Get constraint type associated with the index

Specified by:
getConstraintType in interface AdempiereDatabase
Returns:
String[0] = 0: do not know, 1: Primary Key 2: Foreign Key String[1] - String[n] = Constraint Name

isSupported

public boolean isSupported(String sql)
Check if DBMS support the sql statement

Specified by:
isSupported in interface AdempiereDatabase
Returns:
true: yes

dumpLocks

public static void dumpLocks(Connection conn)
Dump table lock info to console for current transaction

Parameters:
conn -

main

public static void main(String[] args)
Test

Parameters:
args - ignored

Adempiere 3.5.2a

Adempiere® is a registered trademark of ADempiere Business Inc. ©2004-2008 HumanFlash.com All rights reserved.