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

📄 sqlca.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                cs.setIntX(7, getSqlErrd()[2]);                cs.setIntX(8, getSqlErrd()[3]);                cs.setIntX(9, getSqlErrd()[4]);                cs.setIntX(10, getSqlErrd()[5]);                // SQLWarn: SQL warning flags.                cs.setStringX(11, new String(getSqlWarn()));                // SQLState: standard SQL state.                cs.setStringX(12, getSqlState());                // MessageFileName: Not used by our driver, so set to null.                cs.setStringX(13, null);                // Locale: language preference requested for the return error message.                cs.setStringX(14, java.util.Locale.getDefault().toString());                // server could return a locale different from what we requested                cs.registerOutParameterX(14, java.sql.Types.VARCHAR);                // Message: error message returned from SQLCAMessage stored procedure.                cs.registerOutParameterX(15, java.sql.Types.LONGVARCHAR);                // RCode: return code from SQLCAMessage stored procedure.                cs.registerOutParameterX(16, java.sql.Types.INTEGER);                cs.executeX();                if (cs.getIntX(16) == 0) {                    // Return the message text.                    messageTextRetrievedContainsTokensOnly_ = false;                    String message = cs.getStringX(15);                    cachedMessage = message;                    return message;                } else {                    // Stored procedure can't return a valid message text, so we return                    // unformated exception                    return getUnformattedMessage();                }            } finally {                if (cs != null) {                    try {                        cs.closeX();                    } catch (java.sql.SQLException doNothing) {                    }                }            }        }    }    // May or may not get the formatted message depending upon datasource directives.  cannot throw exeption.    public synchronized String getJDBCMessage() {        // The transient connection_ member will only be null if the Sqlca has been deserialized        if (connection_ != null && connection_.retrieveMessageText_) {            try {                return getMessage();            } catch (SqlException e) {                // Invocation of stored procedure fails, so we return error message tokens directly.                exceptionThrownOnStoredProcInvocation_ = e;                chainDeferredExceptionsToAgentOrAsConnectionWarnings((SqlException) e);                return getUnformattedMessage();            }        } else {            return getUnformattedMessage();        }    }    private String getUnformattedMessage() {        return "DERBY SQL error: SQLCODE: " + getSqlCode() + ", SQLSTATE: " + getSqlState() + ", SQLERRMC: " + getSqlErrmc();    }    private void chainDeferredExceptionsToAgentOrAsConnectionWarnings(SqlException e) {        SqlException current = e;        while (current != null) {            SqlException next = (SqlException) current.getNextException();            current = current.copyAsUnchainedSQLException(agent_.logWriter_);            if (current.getErrorCode() == -440) {                SqlWarning warningForStoredProcFailure = new SqlWarning(agent_.logWriter_,                        " Unable to obtain message text from server." +                        " See chained exception." +                        " The stored procedure SYSIBM.SQLCAMESSAGE is not installed on server." +                        " Contact your DBA.");                warningForStoredProcFailure.setNextException(current);                connection_.accumulate440WarningForMessageProcFailure(warningForStoredProcFailure);            } else if (current.getErrorCode() == -444) {                SqlWarning warningForStoredProcFailure = new SqlWarning(agent_.logWriter_,                        " Unable to obtain message text from server." +                        " See chained exception." +                        " The stored procedure SYSIBM.SQLCAMESSAGE cannot be accessed on the server." +                        " Contact your DBA.");                warningForStoredProcFailure.setNextException(current);                connection_.accumulate444WarningForMessageProcFailure(warningForStoredProcFailure);            } else {                agent_.accumulateDeferredException(current);            }            current = next;        }    }    public boolean includesSqlCode(int[] codes) {        for (int i = 0; i < codes.length; i++) {            if (codes[i] == getSqlCode()) {                return true;            }        }        return false;    }    // ------------------- helper methods ----------------------------------------    private String[] processSqlErrmcTokens(byte[] tokenBytes) {        if (tokenBytes == null) {            return null;        }        // create 0-length String tokens array if tokenBytes is 0-length        int length = tokenBytes.length;        if (length == 0) {            return new String[0];        }        try {            // tokenize and convert tokenBytes            java.io.ByteArrayOutputStream buffer = new java.io.ByteArrayOutputStream();            java.util.LinkedList tokens = new java.util.LinkedList();            // parse the error message tokens            for (int index = 0; index < length - 1; index++) {                // non-delimiter - continue to write into buffer                if (tokenBytes[index] != -1)  // -1 is the delimiter '\xFF'                {                    buffer.write(tokenBytes[index]);                }                // delimiter - convert current token and add to list                else {                    tokens.add(bytes2String(buffer.toByteArray(), 0, buffer.size()));                    buffer.reset();                }            }            int lastIndex = length - 1;            // check for last byte not being a delimiter, i.e. part of last token            if (tokenBytes[lastIndex] != -1) {                // write the last byte                buffer.write(tokenBytes[lastIndex]);                // convert the last token and add to list                tokens.add(bytes2String(buffer.toByteArray(), 0, buffer.size()));            }            // last byte is delimiter implying an empty String for last token            else {                // convert current token, if one exists, and add to list                if (lastIndex != 0) {                    tokens.add(bytes2String(buffer.toByteArray(), 0, buffer.size()));                }                // last token is an empty String                tokens.add("");            }            // create the String array and fill it with tokens.            String[] tokenStrings = new String[tokens.size()];            java.util.Iterator iterator = tokens.iterator();            for (int i = 0; iterator.hasNext(); i++) {                tokenStrings[i] = (String) iterator.next();            }            return tokenStrings;        } catch (java.io.UnsupportedEncodingException e) {            return null;        }    }    private String bytes2String(byte[] bytes, int offset, int length)            throws java.io.UnsupportedEncodingException {        // Network Server uses UTF-8 encoding        return new String(bytes, offset, length,Typdef.UTF8ENCODING);    }    public int getUpdateCount() {        if (sqlErrd_ == null) {            return 0;        }        return sqlErrd_[2];    }    public long getRowCount() throws org.apache.derby.client.am.DisconnectException {        return ((long) sqlErrd_[0] << 32) + sqlErrd_[1];    }    public void setContainsSqlcax(boolean containsSqlcax) {        containsSqlcax_ = containsSqlcax;    }    public boolean containsSqlcax() {        return containsSqlcax_;    }    public void resetRowsetSqlca(org.apache.derby.client.am.Connection connection,                                 int sqlCode,                                 byte[] sqlStateBytes,                                 byte[] sqlErrpBytes,                                 int ccsid) {        connection_ = connection;        sqlCode_ = sqlCode;        sqlStateBytes_ = sqlStateBytes;        sqlErrpBytes_ = sqlErrpBytes;        ccsid_ = ccsid;    }    public void setRowsetRowCount(long rowCount) {        rowsetRowCount_ = rowCount;    }    public long getRowsetRowCount() {        return rowsetRowCount_;    }}

⌨️ 快捷键说明

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