⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connection.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*   Derby - Class org.apache.derby.client.am.Connection   Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable.   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License.*/package org.apache.derby.client.am;import org.apache.derby.jdbc.ClientDataSource;import java.sql.SQLException;public abstract class Connection implements java.sql.Connection,        ConnectionCallbackInterface {    //---------------------navigational members-----------------------------------    public Agent agent_;    public DatabaseMetaData databaseMetaData_;    // DERBY-210 -  WeakHashMap is used to store references to objects to avoid    // memory leaks. When there are no other references to the keys in a     // WeakHashMap, they will get removed from the map and can thus get     // garbage-collected. They do not have to wait till the Connection object     // is collected.            // In Connection.markStatementsClosed() method, this list is traversed to get a    // list of open statements, which are marked closed and removed from the list.    final java.util.WeakHashMap openStatements_ = new java.util.WeakHashMap();    // Some statuses of DERBY objects may be invalid on server    // after both commit and rollback. For example,    // (1) prepared statements need to be re-prepared    //     after both commit and rollback    // (2) result set will be unpositioned on server after both commit and rollback.    // If they depend on both commit and rollback, they need to get on CommitAndRollbackListeners_.    final java.util.WeakHashMap CommitAndRollbackListeners_ = new java.util.WeakHashMap();    private SqlWarning warnings_ = null;    // ------------------------properties set for life of connection--------------    // See ClientDataSource pre-connect settings    public transient String user_;    public boolean retrieveMessageText_;    protected boolean jdbcReadOnly_;    /**     * Holdabilty for created statements.     * Only access through the holdability method     * to ensure the correct value is returned for an     * XA connection.     */    private int holdability = ClientDataSource.HOLD_CURSORS_OVER_COMMIT;    public String databaseName_;    // Holds the Product-Specific Identifier which specifies    // the product release level of a DDM Server.    // The max length is 8.    public String productID_;    // Used to get the public key and encrypt password and/or userid    protected EncryptionManager encryptionManager_;    // used to set transaction isolation level    private Statement setTransactionIsolationStmt = null;        // used to get transaction isolation level    private Statement getTransactionIsolationStmt = null;        // ------------------------dynamic properties---------------------------------    protected boolean open_ = true;    protected boolean availableForReuse_ = false;    public int isolation_ = Configuration.defaultIsolation;    public boolean autoCommit_ = true;    protected boolean inUnitOfWork_ = false; // This means a transaction is in progress.    private boolean accumulated440ForMessageProcFailure_ = false;    private boolean accumulated444ForMessageProcFailure_ = false;    private boolean accumulatedSetReadOnlyWarning_ = false;    //---------------------XA-----------------------------------------------------    protected boolean isXAConnection_ = false; // Indicates an XA connection    // XA States    // The client needs to keep track of the connection's transaction branch association    // per table 2.6 in the XA+ specification in order to determine if commits should flow in    // autocommit mode.  There is no need to keep track of suspended transactions separately from    // XA_TO_NOT_ASSOCIATED.    //     /**     * <code>XA_T0_NOT_ASSOCIATED</code>     * This connection is not currently associated with an XA transaction     * In this state commits will flow in autocommit mode.     */    public static final int XA_T0_NOT_ASSOCIATED = 0;           /**     * <code>XA_T1_ASSOCIATED</code>     * In this state commits will not flow in autocommit mode.     */    public static final int XA_T1_ASSOCIATED = 1;          //TODO: Remove XA_RECOVER entirely once indoubtlist is gone.      //public static final int XA_RECOVER = 14;    private int xaState_ = XA_T0_NOT_ASSOCIATED;    // XA Host Type    public int xaHostVersion_ = 0;    public int loginTimeout_;    public org.apache.derby.jdbc.ClientDataSource dataSource_;    public String serverNameIP_;    public int portNumber_;    public java.util.Hashtable clientCursorNameCache_ = new java.util.Hashtable();    public boolean canUseCachedConnectBytes_ = false;    public int commBufferSize_ = 32767;    // indicates if a deferred reset connection is required    public boolean resetConnectionAtFirstSql_ = false;    //---------------------constructors/finalizer---------------------------------    // For jdbc 2 connections    protected Connection(org.apache.derby.client.am.LogWriter logWriter,                         String user,                         String password,                         org.apache.derby.jdbc.ClientDataSource dataSource) throws SqlException {        initConnection(logWriter, user, dataSource);    }    protected Connection(org.apache.derby.client.am.LogWriter logWriter,                         String user,                         String password,                         boolean isXAConn,                         org.apache.derby.jdbc.ClientDataSource dataSource) throws SqlException {        isXAConnection_ = isXAConn;        initConnection(logWriter, user, dataSource);    }    // For jdbc 2 connections    protected void initConnection(org.apache.derby.client.am.LogWriter logWriter,                                  String user,                                  org.apache.derby.jdbc.ClientDataSource dataSource) throws SqlException {        if (logWriter != null) {            logWriter.traceConnectEntry(dataSource);        }        org.apache.derby.client.am.Configuration.checkForExceptionsFromLoadConfiguration(logWriter);        user_ = user;        // Extract common properties.        // Derby-409 fix        if (dataSource.getConnectionAttributes() != null) {            databaseName_ = dataSource.getDatabaseName() + ";" + dataSource.getConnectionAttributes();        } else {            databaseName_ = dataSource.getDatabaseName();        }        retrieveMessageText_ = dataSource.getRetrieveMessageText();        loginTimeout_ = dataSource.getLoginTimeout();        dataSource_ = dataSource;        serverNameIP_ = dataSource.getServerName();        portNumber_ = dataSource.getPortNumber();        agent_ = newAgent_(logWriter,                loginTimeout_,                serverNameIP_,                portNumber_);    }    // For jdbc 2 connections    protected Connection(org.apache.derby.client.am.LogWriter logWriter,                         boolean isXAConn,                         org.apache.derby.jdbc.ClientDataSource dataSource) throws SqlException {        if (logWriter != null) {            logWriter.traceConnectEntry(dataSource);        }        isXAConnection_ = isXAConn;        org.apache.derby.client.am.Configuration.checkForExceptionsFromLoadConfiguration(logWriter);        user_ = ClientDataSource.propertyDefault_user;        // Extract common properties.        databaseName_ = dataSource.getDatabaseName();        retrieveMessageText_ = dataSource.getRetrieveMessageText();        loginTimeout_ = dataSource.getLoginTimeout();        dataSource_ = dataSource;        serverNameIP_ = dataSource.getServerName();        portNumber_ = dataSource.getPortNumber();        agent_ = newAgent_(logWriter,                loginTimeout_,                serverNameIP_,                portNumber_);    }    // This is a callback method, called by subsystem - NetConnection    protected void resetConnection(LogWriter logWriter,                                   String user,                                   ClientDataSource ds,                                   boolean recomputeFromDataSource) throws SqlException {        // clearWarningsX() will re-initialize the following properties        clearWarningsX();        user_ = (user != null) ? user : user_;        if (ds != null && recomputeFromDataSource) { // no need to reinitialize connection state if ds hasn't changed            user_ = (user != null) ? user : ds.getUser();            ;            retrieveMessageText_ = ds.getRetrieveMessageText();            // property encryptionManager_            // if needed this will later be initialized by NET calls to initializePublicKeyForEncryption()            encryptionManager_ = null;            // property: open_            // this should already be true            isolation_ = Configuration.defaultIsolation;            autoCommit_ = true;            inUnitOfWork_ = false;            loginTimeout_ = ds.getLoginTimeout();            dataSource_ = ds;                        holdability = ClientDataSource.HOLD_CURSORS_OVER_COMMIT;        }                if (recomputeFromDataSource) {            this.agent_.resetAgent(this, logWriter, loginTimeout_, serverNameIP_, portNumber_);        }    }    protected void resetConnection(LogWriter logWriter,                                   String databaseName,                                   java.util.Properties properties) throws SqlException {        // clearWarningsX() will re-initialize the following properties        // warnings_, accumulated440ForMessageProcFailure_,        // accumulated444ForMessageProcFailure_, and accumulatedSetReadOnlyWarning_        clearWarningsX();        databaseName_ = databaseName;        user_ = ClientDataSource.getUser(properties);        retrieveMessageText_ = ClientDataSource.getRetrieveMessageText(properties);        // property encryptionManager_        // if needed this will later be initialized by NET calls to initializePublicKeyForEncryption()        encryptionManager_ = null;        // property: open_        // this should already be true        isolation_ = Configuration.defaultIsolation;        autoCommit_ = true;        inUnitOfWork_ = false;        this.agent_.resetAgent(this, logWriter, loginTimeout_, serverNameIP_, portNumber_);    }    // For jdbc 1 connections    protected Connection(LogWriter logWriter,                         int driverManagerLoginTimeout,                         String serverName,                         int portNumber,                         String databaseName,                         java.util.Properties properties) throws SqlException {        if (logWriter != null) {            logWriter.traceConnectEntry(serverName, portNumber, databaseName, properties);        }        org.apache.derby.client.am.Configuration.checkForExceptionsFromLoadConfiguration(logWriter);        databaseName_ = databaseName;        // Extract common properties.        user_ = ClientDataSource.getUser(properties);        retrieveMessageText_ = ClientDataSource.getRetrieveMessageText(properties);        loginTimeout_ = driverManagerLoginTimeout;        serverNameIP_ = serverName;        portNumber_ = portNumber;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -