Package org.compiere.db
Class CConnection
- java.lang.Object
-
- 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<marek.mosiewicz@jotel.com.pl> - support for RMI over HTTP
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CConnection(String host)
Adempiere Connection
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Object
clone()
String
convertStatement(String origStatement)
Convert Statementboolean
equals(Object o)
Equalsstatic CConnection
get()
Get/Set default client/server Connectionstatic CConnection
get(String apps_host)
Deprecated.static CConnection
get(String type, String db_host, int db_port, String db_name)
Get specific connectionstatic CConnection
get(String type, String db_host, int db_port, String db_name, String db_uid, String db_pwd)
Get specific client connectionString
getAppsHost()
Get Application HostConnection
getConnection(boolean autoCommit, int transactionIsolation)
Create Connection - no not close.String
getConnectionURL()
Get Connection StringAdempiereDatabase
getDatabase()
Get DatabaseException
getDatabaseException()
Get Database Exception of last connection attemptDataSource
getDataSource()
Get Server ConnectionString
getDbHost()
Get Database Host nameString
getDBInfo()
Get DB Version InfoString
getDbName()
Get Database Name (Service Name)int
getDbPort()
Get DB PortString
getDbPwd()
Get Database PasswordString
getDbUid()
Get Database UserString
getFwHost()
Method getFwHostint
getFwPort()
Get Firewall portString
getInfo()
Get InfoInitialContext
getInitialContext(boolean useCache)
Get Application Server Initial ContextString
getName()
Get NameString
getServerVersion()
Get Apps Server Versionint
getSSLPort()
String
getStatus()
Get Status Infostatic String
getTransactionIsolationInfo(int transactionIsolation)
Get Transaction Isolation InfoString
getType()
Get Database Typeint
getWebPort()
int
hashCode()
Hashcodeboolean
isBequeath()
Is it a bequeath connectionboolean
isDatabaseOK()
Is Database Connection OKboolean
isDataSource()
Has Server Connectionboolean
isOracle()
Is Oracle DBboolean
isPostgreSQL()
Is PostgreSQL DBboolean
isRMIoverHTTP()
Deprecated.boolean
isServerObjects()
Deprecated.boolean
isServerProcess()
Deprecated.boolean
isTerminalServer()
Deprecated.boolean
isViaFirewall()
Is DB via Firewallvoid
readInfo(Connection conn)
void
setAppsHost(String apps_host)
Set Application Hostvoid
setBequeath(boolean bequeath)
Set Bequeathvoid
setBequeath(String bequeathString)
Set Bequeathboolean
setDataSource()
Create DB Connectionboolean
setDataSource(DataSource ds)
Set Data Sourcevoid
setDbHost(String db_host)
Set Database host namevoid
setDbName(String db_name)
Set Database Name (Service Name)void
setDbPort(int db_port)
Set DB Portvoid
setDbPort(String db_portString)
Set DB Portvoid
setDbPwd(String db_pwd)
Set DB passwordvoid
setDbUid(String db_uid)
Set Database Uservoid
setFwHost(String fw_host)
Method setFwHostvoid
setFwPort(int fw_port)
Set Firewall portvoid
setFwPort(String fw_portString)
Set Firewall portvoid
setName()
Set Namevoid
setName(String name)
Set Namevoid
setSSLPort(int sslPort)
set ssl portvoid
setSSLPort(String sslPortString)
Set SSL Portvoid
setType(String type)
Set Database Type and default settings.void
setViaFirewall(boolean viaFirewall)
Method setViaFirewallvoid
setViaFirewall(String viaFirewallString)
Method setViaFirewallvoid
setWebPort(int webPort)
set web portvoid
setWebPort(String webPortString)
Set Web Portboolean
supportsBLOB()
Supports BLOBException
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.0String
toString()
Short String representationString
toStringDetail()
Detail InfoString
toStringLong()
String representation.String
toStringLong(boolean includePass)
String representation.
-
-
-
Constructor Detail
-
CConnection
public CConnection(String host)
Adempiere Connection- Parameters:
host
- optional application/db host
-
-
Method Detail
-
get
public static CConnection get()
Get/Set default client/server Connection- Returns:
- Connection Descriptor
-
get
public static CConnection get(String apps_host)
Deprecated.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_ORACLEdb_host
- db hostdb_port
- db portdb_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_ORACLEdb_host
- db hostdb_port
- db portdb_name
- db namedb_uid
- db user iddb_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
public 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
-
getWebPort
public int getWebPort()
- Returns:
- web port
-
setWebPort
public void setWebPort(int webPort)
set web port- Parameters:
webPort
-
-
setWebPort
public void setWebPort(String webPortString)
Set Web Port- Parameters:
webPortString
- web port as String
-
getSSLPort
public int getSSLPort()
- Returns:
- ssl port
-
setSSLPort
public void setSSLPort(int sslPort)
set ssl port- Parameters:
sslPort
-
-
setSSLPort
public void setSSLPort(String sslPortString)
Set SSL Port- Parameters:
sslPortString
- web port as String
-
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()
Deprecated.RMI over HTTP Deprecated, always return false- Returns:
- true if RMI over HTTP (Wan Connection Profile)
-
isServerObjects
public boolean isServerObjects()
Deprecated.Should objects be created on Server ?- Returns:
- true if client and VPN/WAN
-
isServerProcess
public boolean isServerProcess()
Deprecated.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
-
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 Instantiation- Returns:
- string representation
- See Also:
setAttributes
-
toStringLong
public String toStringLong(boolean includePass)
String representation. Used also for Instantiation- Parameters:
includePass
- flag to include the password in the String- Returns:
- string representation
- See Also:
setAttributes
-
equals
public boolean equals(Object o)
Equals
-
getInfo
public String getInfo()
Get Info. - Database, Driver, Status Info- Returns:
- info
-
hashCode
public int hashCode()
Hashcode
-
getDatabase
public AdempiereDatabase getDatabase()
Get Database- Returns:
- database
-
getConnectionURL
public String getConnectionURL()
Get Connection String- Returns:
- connection string
-
getConnection
public Connection getConnection(boolean autoCommit, int transactionIsolation)
Create Connection - no not close. Sets m_dbException- Parameters:
autoCommit
- true if autocommit connectiontransactionIsolation
- 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
-
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
-
clone
public Object clone() throws CloneNotSupportedException
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
-