Compiere 3.1

org.compiere.db
Class CConnection

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

public class CConnection
extends Object
implements Serializable

Compiere Connection Descriptor

Version:
$Id: CConnection.java,v 1.5 2006/07/30 00:55:13 jjanke Exp $
Author:
Jorg Janke
See Also:
Serialized Form

Field Summary
static ValueNamePair[] appsTypeProfiles
           
static ValueNamePair[] CONNECTIONProfiles
          Connection profiles
static ValueNamePair[] CONNECTIONProfilesWas
           
static String PROFILE_LAN
          Connection Profile LAN
static String PROFILE_TERMINAL
          Connection Profile Terminal Server
static String PROFILE_VPN
          Connection Profile VPM
static String PROFILE_WAN
          Connection Profile WAN
 
Method Summary
 String convertStatement(String origStatement)
          Convert Statement
 Connection createConnection(boolean autoCommit, int transactionIsolation)
          Create Connection - no not close.
 boolean equals(Object o)
          Equals
static CConnection get()
          Get/Set default client/server Connection
static CConnection get(String jdbcString, String db_uid, String db_pwd)
          Get specific connection
static CConnection get(String type, String db_host, String db_port, String db_name)
          Get specific connection
static CConnection get(String type, String db_host, String 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
 String getAppsType()
          Get Application type
 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
 CompiereDatabase 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 getDBType()
          Get Database Type
 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<String,String> env)
          Get Initial Context
static Hashtable<String,String> getInitialEnvironment(String AppsHost, int AppsPort, String appsType, boolean RMIoverHTTP, int webPort)
          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
 Status getStatusEjbStub()
           
static String getTransactionIsolationInfo(int transactionIsolation)
          Get Transaction Isolation Info
 int getWebPort()
          Get Web Port
 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 isDB2()
          Is IBM DB/2
 boolean isMSSQLServer()
          Is Microsoft SQL Server
 boolean isOracle()
          Is Oracle DB
 boolean isOracleXE()
          Is Oracle XE DB
 boolean isPostgreSQL()
          Is PostgrSQL
 boolean isRMIoverHTTP()
          RMI over HTTP
 boolean isServerObjects()
          Should objects be created on Server ?
 boolean isServerProcess()
          Should processes be created on Server ?
 boolean isTerminalServer()
          Is this a Terminal Server ?
 boolean isViaFirewall()
          Is DB via Firewall
static void main(String[] args)
          Testing
 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 setAppsType(String appsType)
          Set Application Type
 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 setDBType(String type)
          Set Database Type and default settings.
 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 setViaFirewall(boolean viaFirewall)
          Method setViaFirewall
 void setViaFirewall(String viaFirewallString)
          Method setViaFirewall
 void setWebPort(int webPort)
          Set Web Port
 void setWebPort(String webPort)
          Set Web Port
 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
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CONNECTIONProfiles

public static ValueNamePair[] CONNECTIONProfiles
Connection profiles


CONNECTIONProfilesWas

public static ValueNamePair[] CONNECTIONProfilesWas

PROFILE_LAN

public static final String PROFILE_LAN
Connection Profile LAN

See Also:
Constant Field Values

PROFILE_TERMINAL

public static final String PROFILE_TERMINAL
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

appsTypeProfiles

public static ValueNamePair[] appsTypeProfiles
Method Detail

get

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

Returns:
Connection Descriptor

get

public static CConnection get(String type,
                              String db_host,
                              String 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 jdbcString,
                              String db_uid,
                              String db_pwd)
Get specific connection

Parameters:
jdbcString - e.g. dbc:oracle:thin:@//ws-jj:1521/xe
db_uid - db user id
db_pwd - db user password
Returns:
connection

get

public static CConnection get(String type,
                              String db_host,
                              String 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

getAppsType

public String getAppsType()
Get Application type

Returns:
application type

setAppsType

public void setAppsType(String appsType)
Set Application Type

Parameters:
appsType - application type

getWebPort

public int getWebPort()
Get Web Port

Returns:
port

setWebPort

public void setWebPort(int webPort)
Set Web Port

Parameters:
webPort - web port

setWebPort

public void setWebPort(String webPort)
Set Web Port

Parameters:
webPort - String web 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 processes be created on Server ?

Returns:
true if client and VPN/WAN

isTerminalServer

public boolean isTerminalServer()
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)

getDBType

public String getDBType()
Get Database Type

Returns:
database type

setDBType

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

Parameters:
type - database Type, e.g. Environemnt.DBTYPE_ORACLE

supportsBLOB

public boolean supportsBLOB()
Supports BLOB

Returns:
true if BLOB is supported

isOracleXE

public boolean isOracleXE()
Is Oracle XE DB

Returns:
true if Oracle XE

isOracle

public boolean isOracle()
Is Oracle DB

Returns:
true if Oracle

isDB2

public boolean isDB2()
Is IBM DB/2

Returns:
true if DB/2

isMSSQLServer

public boolean isMSSQLServer()
Is Microsoft SQL Server

Returns:
true if Microsoft

isPostgreSQL

public boolean isPostgreSQL()
Is PostgrSQL

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

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 CompiereDatabase 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

createConnection

public Connection createConnection(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<String,String> getInitialEnvironment(String AppsHost,
                                                             int AppsPort,
                                                             String appsType,
                                                             boolean RMIoverHTTP,
                                                             int webPort)
Get Initial Environment

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

getInitialContext

public static InitialContext getInitialContext(Hashtable<String,String> 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

getStatusEjbStub

public Status getStatusEjbStub()

main

public static void main(String[] args)
Testing

Parameters:
args - ignored

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.