Adempiere 3.5.2a

org.compiere.db
Class CConnection

java.lang.Object
  extended by org.compiere.db.CConnection
All Implemented Interfaces:
Serializable, Cloneable

public class CConnection
extends Object
implements Serializable, Cloneable

Adempiere Connection Descriptor

Version:
$Id: CConnection.java,v 1.5 2006/07/30 00:55:13 jjanke Exp $
Author:
Jorg Janke, Marek Mosiewicz - support for RMI over HTTP
See Also:
Serialized Form

Field Summary
static ValueNamePair[] CONNECTIONProfiles
          Connection profiles
static String PROFILE_LAN
          Connection Profile LAN
static String PROFILE_TERMINAL
          Deprecated.  
static String PROFILE_VPN
          Connection Profile VPM
static String PROFILE_WAN
          Connection Profile WAN
 
Method Summary
 Object clone()
           
 String convertStatement(String origStatement)
          Convert Statement
 boolean equals(Object o)
          Equals
static CConnection get()
          Get/Set default client/server Connection
static CConnection get(String apps_host)
          Get/Set default client/server Connection
static CConnection get(String type, String db_host, int db_port, String db_name)
          Get specific connection
static CConnection get(String type, String db_host, int db_port, String db_name, String db_uid, String db_pwd)
          Get specific client connection
 String getAppsHost()
          Get Application Host
 int getAppsPort()
          Get Apps Port
 Exception getAppsServerException()
          Get Last Exception of Apps Server Connection attempt
 Connection getConnection(boolean autoCommit, int transactionIsolation)
          Create Connection - no not close.
 String getConnectionProfile()
          Get Connection Profile
 ValueNamePair getConnectionProfilePair()
          Get Connection Profile
 String getConnectionProfileText()
          Get Connection Profile Text
 String getConnectionProfileText(String connectionProfile)
          Get Connection Profile Text
 String getConnectionURL()
          Get Connection String
 AdempiereDatabase getDatabase()
          Get Database
 Exception getDatabaseException()
          Get Database Exception of last connection attempt
 DataSource getDataSource()
          Get Server Connection
 String getDbHost()
          Get Database Host name
 String getDBInfo()
          Get DB Version Info
 String getDbName()
          Get Database Name (Service Name)
 int getDbPort()
          Get DB Port
 String getDbPwd()
          Get Database Password
 String getDbUid()
          Get Database User
 String getFwHost()
          Method getFwHost
 int getFwPort()
          Get Firewall port
 String getInfo()
          Get Info
 InitialContext getInitialContext(boolean useCache)
          Get Application Server Initial Context
static InitialContext getInitialContext(Hashtable env)
          Get Initial Context
static Hashtable getInitialEnvironment(String AppsHost, int AppsPort, boolean RMIoverHTTP)
           
static Hashtable getInitialEnvironment(String AppsHost, int AppsPort, boolean RMIoverHTTP, String principal, String credential)
          Get Initial Environment
 String getName()
          Get Name
 Server getServer()
          Get Server
 Connection getServerConnection(boolean autoCommit, int trxLevel)
          Get Server Connection - do close
 String getServerVersion()
          Get Apps Server Version
 String getStatus()
          Get Status Info
static String getTransactionIsolationInfo(int transactionIsolation)
          Get Transaction Isolation Info
 String getType()
          Get Database Type
 int hashCode()
          Hashcode
 boolean isAppsServerOK(boolean tryContactAgain)
          Is Application Server OK
 boolean isBequeath()
          Is it a bequeath connection
 boolean isDatabaseOK()
          Is Database Connection OK
 boolean isDataSource()
          Has Server Connection
 boolean isOracle()
          Is Oracle DB
 boolean isPostgreSQL()
          Is PostgreSQL DB
 boolean isRMIoverHTTP()
          RMI over HTTP
 boolean isServerObjects()
          Should objects be created on Server ?
 boolean isServerProcess()
          Should objects be created on Server ?
 boolean isTerminalServer()
          Deprecated.  
 boolean isViaFirewall()
          Is DB via Firewall
static void main(String[] args)
          Testing
 void readInfo(Connection conn)
           
 void setAppServerCredential(String principal, String credential)
           
 void setAppsHost(String apps_host)
          Set Application Host
 void setAppsPort(int apps_port)
          Set Apps Port
 void setAppsPort(String apps_portString)
          Set Apps Port
 void setBequeath(boolean bequeath)
          Set Bequeath
 void setBequeath(String bequeathString)
          Set Bequeath
 void setConnectionProfile(String connectionProfile)
          Set Connection Profile
 void setConnectionProfile(ValueNamePair connectionProfile)
          Set Connection Profile
 boolean setDataSource()
          Create DB Connection
 boolean setDataSource(DataSource ds)
          Set Data Source
 void setDbHost(String db_host)
          Set Database host name
 void setDbName(String db_name)
          Set Database Name (Service Name)
 void setDbPort(int db_port)
          Set DB Port
 void setDbPort(String db_portString)
          Set DB Port
 void setDbPwd(String db_pwd)
          Set DB password
 void setDbUid(String db_uid)
          Set Database User
 void setFwHost(String fw_host)
          Method setFwHost
 void setFwPort(int fw_port)
          Set Firewall port
 void setFwPort(String fw_portString)
          Set Firewall port
protected  void setName()
          Set Name
 void setName(String name)
          Set Name
 void setType(String type)
          Set Database Type and default settings.
 void setViaFirewall(boolean viaFirewall)
          Method setViaFirewall
 void setViaFirewall(String viaFirewallString)
          Method setViaFirewall
 boolean supportsBLOB()
          Supports BLOB
 Exception testAppsServer()
          Test ApplicationServer
 Exception testDatabase(boolean retest)
          Test Database Connection. -- Example -- Database: PostgreSQL - 7.1.3 Driver: PostgreSQL Native Driver - PostgreSQL 7.2 JDBC2 -- Example -- Database: Oracle - Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production Driver: Oracle JDBC driver - 9.0.1.1.0
 String toString()
          Short String representation
 String toStringDetail()
          Detail Info
 String toStringLong()
          String representation.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CONNECTIONProfiles

public static ValueNamePair[] CONNECTIONProfiles
Connection profiles


PROFILE_LAN

public static final String PROFILE_LAN
Connection Profile LAN

See Also:
Constant Field Values

PROFILE_TERMINAL

public static final String PROFILE_TERMINAL
Deprecated. 
Connection Profile Terminal Server

See Also:
Constant Field Values

PROFILE_VPN

public static final String PROFILE_VPN
Connection Profile VPM

See Also:
Constant Field Values

PROFILE_WAN

public static final String PROFILE_WAN
Connection Profile WAN

See Also:
Constant Field Values
Method Detail

get

public static CConnection get()
Get/Set default client/server Connection

Returns:
Connection Descriptor

get

public static CConnection get(String apps_host)
Get/Set default client/server Connection

Parameters:
apps_host - optional apps host for new connections
Returns:
Connection Descriptor

get

public static CConnection get(String type,
                              String db_host,
                              int db_port,
                              String db_name)
Get specific connection

Parameters:
type - database Type, e.g. Database.DB_ORACLE
db_host - db host
db_port - db port
db_name - db name
Returns:
connection

get

public static CConnection get(String type,
                              String db_host,
                              int db_port,
                              String db_name,
                              String db_uid,
                              String db_pwd)
Get specific client connection

Parameters:
type - database Type, e.g. Database.DB_ORACLE
db_host - db host
db_port - db port
db_name - db name
db_uid - db user id
db_pwd - db user password
Returns:
connection

getName

public String getName()
Get Name

Returns:
connection name

setName

public void setName(String name)
Set Name

Parameters:
name - connection name

setName

protected void setName()
Set Name


getAppsHost

public String getAppsHost()
Get Application Host

Returns:
apps host

setAppsHost

public void setAppsHost(String apps_host)
Set Application Host

Parameters:
apps_host - apps host

getAppsPort

public int getAppsPort()
Get Apps Port

Returns:
port

setAppsPort

public void setAppsPort(int apps_port)
Set Apps Port

Parameters:
apps_port - apps port

setAppsPort

public void setAppsPort(String apps_portString)
Set Apps Port

Parameters:
apps_portString - appd port as String

isAppsServerOK

public boolean isAppsServerOK(boolean tryContactAgain)
Is Application Server OK

Parameters:
tryContactAgain - try to contact again
Returns:
true if Apps Server exists

testAppsServer

public Exception testAppsServer()
Test ApplicationServer

Returns:
Exception or null

getServer

public Server getServer()
Get Server

Returns:
Server

getServerVersion

public String getServerVersion()
Get Apps Server Version

Returns:
db host name

getDbHost

public String getDbHost()
Get Database Host name

Returns:
db host name

setDbHost

public void setDbHost(String db_host)
Set Database host name

Parameters:
db_host - db host

getDbName

public String getDbName()
Get Database Name (Service Name)

Returns:
db name

setDbName

public void setDbName(String db_name)
Set Database Name (Service Name)

Parameters:
db_name - db name

getDbPort

public int getDbPort()
Get DB Port

Returns:
port

setDbPort

public void setDbPort(int db_port)
Set DB Port

Parameters:
db_port - db port

setDbPort

public void setDbPort(String db_portString)
Set DB Port

Parameters:
db_portString - db port as String

getDbPwd

public String getDbPwd()
Get Database Password

Returns:
db password

setDbPwd

public void setDbPwd(String db_pwd)
Set DB password

Parameters:
db_pwd - db user password

getDbUid

public String getDbUid()
Get Database User

Returns:
db user

setDbUid

public void setDbUid(String db_uid)
Set Database User

Parameters:
db_uid - db user id

isRMIoverHTTP

public boolean isRMIoverHTTP()
RMI over HTTP

Returns:
true if RMI over HTTP (Wan Connection Profile)

setConnectionProfile

public void setConnectionProfile(ValueNamePair connectionProfile)
Set Connection Profile

Parameters:
connectionProfile - connection profile

setConnectionProfile

public void setConnectionProfile(String connectionProfile)
Set Connection Profile

Parameters:
connectionProfile - connection profile

getConnectionProfile

public String getConnectionProfile()
Get Connection Profile

Returns:
connection profile

getConnectionProfileText

public String getConnectionProfileText(String connectionProfile)
Get Connection Profile Text

Parameters:
connectionProfile -
Returns:
connection profile text

getConnectionProfileText

public String getConnectionProfileText()
Get Connection Profile Text

Returns:
connection profile text

getConnectionProfilePair

public ValueNamePair getConnectionProfilePair()
Get Connection Profile

Returns:
connection profile

isServerObjects

public boolean isServerObjects()
Should objects be created on Server ?

Returns:
true if client and VPN/WAN

isServerProcess

public boolean isServerProcess()
Should objects be created on Server ?

Returns:
true if client and Terminal/VPN/WAN

isTerminalServer

public boolean isTerminalServer()
Deprecated. 

Is this a Terminal Server ?

Returns:
true if client and Terminal

isViaFirewall

public boolean isViaFirewall()
Is DB via Firewall

Returns:
true if via firewall

setViaFirewall

public void setViaFirewall(boolean viaFirewall)
Method setViaFirewall

Parameters:
viaFirewall - boolean

setViaFirewall

public void setViaFirewall(String viaFirewallString)
Method setViaFirewall

Parameters:
viaFirewallString - String

getFwHost

public String getFwHost()
Method getFwHost

Returns:
String

setFwHost

public void setFwHost(String fw_host)
Method setFwHost

Parameters:
fw_host - String

getFwPort

public int getFwPort()
Get Firewall port

Returns:
firewall port

setFwPort

public void setFwPort(int fw_port)
Set Firewall port

Parameters:
fw_port - firewall port

setFwPort

public void setFwPort(String fw_portString)
Set Firewall port

Parameters:
fw_portString - firewall port as String

isBequeath

public boolean isBequeath()
Is it a bequeath connection

Returns:
true if bequeath connection

setBequeath

public void setBequeath(boolean bequeath)
Set Bequeath

Parameters:
bequeath - bequeath connection

setBequeath

public void setBequeath(String bequeathString)
Set Bequeath

Parameters:
bequeathString - bequeath connection as String (true/false)

getType

public String getType()
Get Database Type

Returns:
database type

setType

public void setType(String type)
Set Database Type and default settings. Checked against installed databases

Parameters:
type - database Type, e.g. Database.DB_ORACLE

supportsBLOB

public boolean supportsBLOB()
Supports BLOB

Returns:
true if BLOB is supported

isOracle

public boolean isOracle()
Is Oracle DB

Returns:
true if Oracle

isPostgreSQL

public boolean isPostgreSQL()
Is PostgreSQL DB

Returns:
true if PostgreSQL

isDatabaseOK

public boolean isDatabaseOK()
Is Database Connection OK

Returns:
true if database connection is OK

setDataSource

public boolean setDataSource()
Create DB Connection

Returns:
data source != null

setDataSource

public boolean setDataSource(DataSource ds)
Set Data Source

Parameters:
ds - data source
Returns:
data source != null

getDataSource

public DataSource getDataSource()
Get Server Connection

Returns:
DataSource

isDataSource

public boolean isDataSource()
Has Server Connection

Returns:
true if DataSource exists

testDatabase

public Exception testDatabase(boolean retest)
Test Database Connection. -- Example -- Database: PostgreSQL - 7.1.3 Driver: PostgreSQL Native Driver - PostgreSQL 7.2 JDBC2 -- Example -- Database: Oracle - Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production Driver: Oracle JDBC driver - 9.0.1.1.0

Parameters:
retest -
Returns:
Exception or null

readInfo

public void readInfo(Connection conn)
              throws SQLException
Throws:
SQLException

toString

public String toString()
Short String representation

Overrides:
toString in class Object
Returns:
appsHost{dbHost-dbName-uid}

toStringDetail

public String toStringDetail()
Detail Info

Returns:
info

getDBInfo

public String getDBInfo()
Get DB Version Info

Returns:
info

toStringLong

public String toStringLong()
String representation. Used also for Instanciation

Returns:
string representation
See Also:
setAttributes

equals

public boolean equals(Object o)
Equals

Overrides:
equals in class Object
Parameters:
o - object
Returns:
true if o equals this

getInfo

public String getInfo()
Get Info. - Database, Driver, Status Info

Returns:
info

hashCode

public int hashCode()
Hashcode

Overrides:
hashCode in class Object
Returns:
hashcode of name

getDatabase

public AdempiereDatabase getDatabase()
Get Database

Returns:
database

getConnectionURL

public String getConnectionURL()
Get Connection String

Returns:
connection string

getServerConnection

public Connection getServerConnection(boolean autoCommit,
                                      int trxLevel)
Get Server Connection - do close

Parameters:
autoCommit - true if autocommit connection
trxLevel - Connection transaction level
Returns:
Connection

getConnection

public Connection getConnection(boolean autoCommit,
                                int transactionIsolation)
Create Connection - no not close. Sets m_dbException

Parameters:
autoCommit - true if autocommit connection
transactionIsolation - Connection transaction level
Returns:
Connection

getDatabaseException

public Exception getDatabaseException()
Get Database Exception of last connection attempt

Returns:
Exception or null

getInitialContext

public InitialContext getInitialContext(boolean useCache)
Get Application Server Initial Context

Parameters:
useCache - if true, use existing cache
Returns:
Initial Context or null

getInitialEnvironment

public static Hashtable getInitialEnvironment(String AppsHost,
                                              int AppsPort,
                                              boolean RMIoverHTTP)

getInitialEnvironment

public static Hashtable getInitialEnvironment(String AppsHost,
                                              int AppsPort,
                                              boolean RMIoverHTTP,
                                              String principal,
                                              String credential)
Get Initial Environment

Parameters:
AppsHost - host
AppsPort - port
RMIoverHTTP - true if tunnel through HTTP
principal -
credential -
Returns:
environment

getInitialContext

public static InitialContext getInitialContext(Hashtable env)
Get Initial Context

Parameters:
env - environment
Returns:
Initial Context

getAppsServerException

public Exception getAppsServerException()
Get Last Exception of Apps Server Connection attempt

Returns:
Exception or null

convertStatement

public String convertStatement(String origStatement)
                        throws Exception
Convert Statement

Parameters:
origStatement - original statement (Oracle notation)
Returns:
converted Statement
Throws:
Exception

getStatus

public String getStatus()
Get Status Info

Returns:
info

getTransactionIsolationInfo

public static String getTransactionIsolationInfo(int transactionIsolation)
Get Transaction Isolation Info

Parameters:
transactionIsolation - trx iso
Returns:
clear test

setAppServerCredential

public void setAppServerCredential(String principal,
                                   String credential)

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

main

public static void main(String[] args)
Testing

Parameters:
args - ignored

Adempiere 3.5.2a

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