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

📄 connection.java

📁 我费了好大劲才找到的一款非常全的OA办公自动化软件源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public boolean supportsQuotedIdentifiers() {        return this.hasQuotedIdentifiers;    }    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public boolean supportsTransactions() {        return this.transactionsSupported;    }    /**     * Should we use compression?     *     * @return should we use compression to communicate with the server?     */    public boolean useCompression() {        return this.useCompression;    }    /**     * Returns the paranoidErrorMessages.     *     * @return boolean if we should be paranoid about error messages.     */    public boolean useParanoidErrorMessages() {        return paranoid;    }    /**     * Should we use SSL?     *     * @return should we use SSL to communicate with the server?     */    public boolean useSSL() {        return this.useSSL;    }    /**     * Should we enable work-arounds for floating point rounding errors in the     * server?     *     * @return should we use floating point work-arounds?     */    public boolean useStrictFloatingPoint() {        return this.strictFloatingPoint;    }    /**     * Returns the strictUpdates value.     *     * @return boolean     */    public boolean useStrictUpdates() {        return strictUpdates;    }    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public boolean useTimezone() {        return this.useTimezone;    }    /**     * Should unicode character mapping be used ?     *     * @return should we use Unicode character mapping?     */    public boolean useUnicode() {        return this.doUnicode;    }    /**     * Returns the Java character encoding name for the given MySQL server     * charset index     *     * @param charsetIndex     *     * @return the Java character encoding name for the given MySQL server     *         charset index     *     * @throws SQLException if the character set index isn't known by the     *         driver     */    protected String getCharsetNameForIndex(int charsetIndex)        throws SQLException {        String charsetName = null;        if (charsetIndex != MysqlDefs.NO_CHARSET_INFO) {            try {                charsetName = this.indexToCharsetMapping[charsetIndex];            } catch (ArrayIndexOutOfBoundsException outOfBoundsEx) {                throw new SQLException(                    "Unknown character set index for field '" + charsetIndex                    + "' received from server.",                    SQLError.SQL_STATE_GENERAL_ERROR);            }            // Punt            if (charsetName == null) {                charsetName = getEncoding();            }        } else {            charsetName = getEncoding();        }        return charsetName;    }    /**     * DOCUMENT ME!     *     * @return Returns the defaultTimeZone.     */    protected TimeZone getDefaultTimeZone() {        return defaultTimeZone;    }    /**     * Returns the IO channel to the server     *     * @return the IO channel to the server     *     * @throws SQLException if the connection is closed.     */    protected MysqlIO getIO() throws SQLException {        if ((this.io == null) || this.isClosed) {            throw new SQLException("Operation not allowed on closed connection",                "08003");        }        return this.io;    }    protected int getNetWriteTimeout() {        String netWriteTimeoutStr = (String) this.serverVariables.get(                "net_write_timeout");        if (netWriteTimeoutStr != null) {            try {                return Integer.parseInt(netWriteTimeoutStr);            } catch (NumberFormatException nfe) {                return Integer.MAX_VALUE;            }        } else {            return Integer.MAX_VALUE;        }    }    /**     * Is this connection using unbuffered input?     *     * @return whether or not to use buffered input streams     */    protected boolean isUsingUnbufferedInput() {        return this.useUnbufferedInput;    }    /**     * Creates an IO channel to the server     *     * @param isForReconnect is this request for a re-connect     *     * @return a new MysqlIO instance connected to a server     *     * @throws SQLException if a database access error occurs     */    protected com.mysql.jdbc.MysqlIO createNewIO(boolean isForReconnect)        throws SQLException {        MysqlIO newIo = null;        if (!highAvailability && !this.failedOver) {            for (int hostIndex = 0; hostIndex < hostListSize; hostIndex++) {                try {                    String newHostPortPair = (String) this.hostList.get(hostIndex);                    int newPort = 3306;                                        String[] hostPortPair = NonRegisteringDriver.parseHostPortPair(newHostPortPair);                    String newHost = hostPortPair[NonRegisteringDriver.HOST_NAME_INDEX];                	                    if (newHost == null || newHost.trim().length() == 0) {                    	newHost = "localhost";                    }                	                	if (hostPortPair[NonRegisteringDriver.PORT_NUMBER_INDEX] != null) {                		try {                            newPort = Integer.parseInt(hostPortPair[NonRegisteringDriver.PORT_NUMBER_INDEX]);                        } catch (NumberFormatException nfe) {                            throw new SQLException(                                "Illegal connection port value '"                                + hostPortPair[NonRegisteringDriver.PORT_NUMBER_INDEX] + "'",                                SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE);                        }                	}                    this.io = new MysqlIO(newHost, newPort,                            this.socketFactoryClassName, this.props, this,                            this.socketTimeout);                    this.io.doHandshake(this.user, this.password, this.database);                    this.isClosed = false;                    if (this.database.length() != 0) {                        this.io.sendCommand(MysqlDefs.INIT_DB, this.database,                            null);                    }                    // save state from old connection                    boolean autoCommit = getAutoCommit();                    int oldIsolationLevel = getTransactionIsolation();                    boolean oldReadOnly = isReadOnly();                    String oldCatalog = getCatalog();                    // Server properties might be different                    // from previous connection, so initialize                    // again...                    initializePropsFromServer(this.props);                    if (isForReconnect) {                        // Restore state from old connection                        setAutoCommit(autoCommit);                        if (this.hasIsolationLevels) {                            setTransactionIsolation(oldIsolationLevel);                        }                        setCatalog(oldCatalog);                    }                    if (hostIndex != 0) {                        setFailedOverState();                    } else {                        this.failedOver = false;                        if (hostListSize > 1) {                            setReadOnly(false);                        } else {                            setReadOnly(oldReadOnly);                        }                    }                    break; // low-level connection succeeded                } catch (SQLException sqlEx) {                    if (this.io != null) {                        this.io.forceClose();                    }                    String sqlState = sqlEx.getSQLState();                    if ((sqlState == null)                            || !sqlState.equals(                                SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE)) {                        throw sqlEx;                    }                    if ((hostListSize - 1) == hostIndex) {                        throw sqlEx;                    }                } catch (Exception unknownException) {                    if (this.io != null) {                        this.io.forceClose();                    }                    if ((hostListSize - 1) == hostIndex) {                        throw new SQLException(                            "Unable to connect to any hosts due to exception: "                            + unknownException.toString()                            + (this.paranoid ? ""                                             : Util.stackTraceToString(                                unknownException)),                            SQLError.SQL_STATE_COMMUNICATION_LINK_FAILURE);                    }                }            }        } else {            double timeout = this.initialTimeout;            boolean connectionGood = false;            Exception connectionException = null;            for (int hostIndex = 0;                    (hostIndex < hostListSize) && !connectionGood;                    hostIndex++) {                for (int attemptCount = 0;                        !connectionGood && (attemptCount < this.maxReconnects);                        attemptCount++) {                    try {                        if (this.io != null) {                            this.io.forceClose();                        }                        String newHostPortPair = (String) this.hostList.get(hostIndex);                        int newPort = 3306;                                                String[] hostPortPair = NonRegisteringDriver.parseHostPortPair(newHostPortPair);                        String newHost = hostPortPair[NonRegisteringDriver.HOST_NAME_INDEX];                    	                        if (newHost == null || newHost.trim().length() == 0) {                        	newHost = "localhost";                        }                    	                    	if (hostPortPair[NonRegisteringDriver.PORT_NUMBER_INDEX] != null) {                    		try {                                newPort = Integer.parseInt(hostPortPair[NonRegisteringDriver.PORT_NUMBER_INDEX]);                            } catch (NumberFormatException nfe) {                                throw new SQLException(                                    "Illegal connection port value '"                                    + hostPortPair[NonRegisteringDriver.PORT_NUMBER_INDEX] + "'",                                    SQLError.SQL_STATE_INVALID_CONNECTION_ATTRIBUTE);                            }                    	}                        this.io = new MysqlIO(newHost, newPort,                                this.socketFactoryClassName, this.props, this,                                this.socketTimeout);                        this.io.doHandshake(this.user, this.password,                            this.database);                        if (this.database.length() != 0) {                            this.io.sendCommand(MysqlDefs.INIT_DB,                                this.database, null);                        }                        ping();                        this.isClosed = false;                        // save state from old connection                        boolean autoCommit = getAutoCommit();                        int oldIsolationLevel = getTransactionIsolation();                        boolean oldReadOnly = isReadOnly();                        String oldCatalog = getCatalog();                        // Server properties might be different                        // from previous connection, so initialize                        // again...                        initializePropsFromServer(this.props);                        if (isForReconnect) {                            // Restore state from old connection                            setAutoCommit(autoCommit);                            if (this.hasIsolationLevels) {                                setTransactionIsolation(oldIsolationLevel);                            }                            setCatalog(oldCatalog);                        }                        connectionGood = true;                        if (hostIndex != 0) {                            setFailedOverState();                        } else {                            this.failedOver = false;                            if (hostListSize > 1) {                                setReadOnly(false);                            } else {                                setReadOnly(oldReadOnly);                            }                        }                        break;                    } catch (Exception EEE) {                        connectionException = EEE;                        connectionGood = false;                    }                    if (!connectionGood) {                        try {                            Thread.sleep((long) timeout * 1000);                            timeout = timeout * 2;                        } catch (InterruptedException IE) {                            ;                        }                    }                } // end attempt on hosts            } // end iterator through list of hosts                        if (!connectionGood) {                // We've really failed!                throw new SQLException(                    "Server connection failure during 

⌨️ 快捷键说明

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