Class 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 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_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

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