Example usage for java.sql SQLException getCause

List of usage examples for java.sql SQLException getCause

Introduction

In this page you can find the example usage for java.sql SQLException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.apache.jackrabbit.core.persistence.pool.BundleDbPersistenceManager.java

/**
 * {@inheritDoc}//from  www .ja v  a 2 s .  c  o m
 *
 * Basically wraps a JDBC transaction around super.store().
 * 
 * FIXME: the retry logic is almost a duplicate of {@code ConnectionHelper.RetryManager}.
 */
public synchronized void store(final ChangeLog changeLog) throws ItemStateException {
    int failures = 0;
    ItemStateException lastException = null;
    boolean sleepInterrupted = false;
    while (!sleepInterrupted && (blockOnConnectionLoss || failures <= 1)) {
        try {
            conHelper.startBatch();
            super.store(changeLog);
            conHelper.endBatch(true);
            return;
        } catch (SQLException e) {
            // Either startBatch or stopBatch threw it: either way the
            // transaction was not persisted and no action needs to be taken.
            lastException = new ItemStateException(e.getMessage(), e);
        } catch (ItemStateException e) {
            // store call threw it: we need to cancel the transaction
            lastException = e;
            try {
                conHelper.endBatch(false);
            } catch (SQLException e2) {
                DbUtility.logException("rollback failed", e2);
            }

            // if we got here due to a constraint violation and we
            // are running in test mode, we really want to stop
            assert !isIntegrityConstraintViolation(e.getCause());
        }
        failures++;
        log.error("Failed to persist ChangeLog (stacktrace on DEBUG log level), blockOnConnectionLoss = "
                + blockOnConnectionLoss + ": " + lastException);
        log.debug("Failed to persist ChangeLog", lastException);
        if (blockOnConnectionLoss || failures <= 1) { // if we're going to try again
            try {
                Thread.sleep(100);
            } catch (InterruptedException e1) {
                Thread.currentThread().interrupt();
                sleepInterrupted = true;
                log.error("Interrupted: canceling retry of ChangeLog storage");
            }
        }
    }
    throw lastException;
}

From source file:org.idempiere.adinterface.ModelADServiceImpl.java

public WindowTabDataDocument getList(ModelGetListRequestDocument req) {
    boolean connected = getCompiereService().isConnected();

    try {//from w  w w . ja  v  a 2 s.com
        if (!connected)
            getCompiereService().connect();

        WindowTabDataDocument resdoc = WindowTabDataDocument.Factory.newInstance();
        WindowTabData res = resdoc.addNewWindowTabData();
        DataSet ds = res.addNewDataSet();
        ModelGetList modelGetList = req.getModelGetListRequest().getModelGetList();
        String serviceType = modelGetList.getServiceType();
        int cnt = 0;

        ADLoginRequest reqlogin = req.getModelGetListRequest().getADLoginRequest();

        String err = login(reqlogin, webServiceName, "getList", serviceType);
        if (err != null && err.length() > 0) {
            res.setError(err);
            res.setErrorInfo(err);
            res.setSuccess(false);
            return resdoc;
        }
        int roleid = reqlogin.getRoleID();

        // Validate parameters
        modelGetList.setADReferenceID(validateParameter("AD_Reference_ID", modelGetList.getADReferenceID()));
        modelGetList.setFilter(validateParameter("Filter", modelGetList.getFilter()));

        int ref_id = modelGetList.getADReferenceID();
        String filter = modelGetList.getFilter();
        if (filter == null || filter.length() == 0)
            filter = "";
        else
            filter = " AND " + filter;

        CompiereService m_cs = getCompiereService();

        Properties ctx = m_cs.getCtx();

        X_AD_Reference ref = new X_AD_Reference(ctx, ref_id, null);

        String sql = null;
        ArrayList<String> listColumnNames = new ArrayList<String>();
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        MWebServiceType m_webservicetype = getWebServiceType();
        if (X_AD_Reference.VALIDATIONTYPE_ListValidation.equals(ref.getValidationType())) {
            // Fill List Reference
            String ad_language = Env.getAD_Language(ctx);
            boolean isBaseLanguage = Env.isBaseLanguage(ad_language, "AD_Ref_List");
            sql = isBaseLanguage
                    ? "SELECT AD_Ref_List.AD_Ref_List_ID, AD_Ref_List.Value, AD_Ref_List.Name, AD_Ref_List.Description "
                            + "FROM AD_Ref_List "
                            + "WHERE AD_Ref_List.AD_Reference_ID=? AND AD_Ref_List.IsActive='Y' " + filter
                            + " ORDER BY AD_Ref_List.Name"
                    : "SELECT AD_Ref_List.AD_Ref_List_ID, AD_Ref_List.Value, AD_Ref_List_Trl.Name, AD_Ref_List_Trl.Description "
                            + "FROM AD_Ref_List, AD_Ref_List_Trl "
                            + "WHERE AD_Ref_List.AD_Reference_ID=? AND AD_Ref_List.IsActive='Y' AND AD_Ref_List_Trl.AD_Language=? AND AD_Ref_List.AD_Ref_List_ID=AD_Ref_List_Trl.AD_Ref_List_ID "
                            + filter + " ORDER BY AD_Ref_List_Trl.Name";
            listColumnNames.add("AD_Ref_List_ID");
            listColumnNames.add("Value");
            listColumnNames.add("Name");
            listColumnNames.add("Description");
            try {
                pstmt = DB.prepareStatement(sql, null);
                pstmt.setInt(1, ref_id);
                if (!isBaseLanguage)
                    pstmt.setString(2, ad_language);
                rs = pstmt.executeQuery();
            } catch (SQLException e) {
                res.setError(e.getMessage());
                res.setErrorInfo(sql);
                res.setSuccess(false);
                DB.close(rs, pstmt);
                rs = null;
                pstmt = null;
                throw new IdempiereServiceFault(e.getClass().toString() + " " + e.getMessage() + " sql=" + sql,
                        e.getCause(), new QName("getList"));
            }

        } else if (X_AD_Reference.VALIDATIONTYPE_TableValidation.equals(ref.getValidationType())) {
            // Fill values from a reference table
            MRole role = new MRole(ctx, roleid, null);
            String sqlrt = "SELECT * FROM AD_Ref_Table WHERE AD_Reference_ID=?";
            MRefTable rt = null;
            PreparedStatement pstmtrt = null;
            ResultSet rsrt = null;
            try {
                pstmtrt = DB.prepareStatement(sqlrt, null);
                pstmtrt.setInt(1, ref_id);
                rsrt = pstmtrt.executeQuery();
                if (rsrt.next())
                    rt = new MRefTable(ctx, rsrt, null);
            } catch (Exception e) {
                // ignore this exception
            } finally {
                DB.close(rsrt, pstmtrt);
                rsrt = null;
                pstmtrt = null;
            }
            if (rt == null)
                throw new IdempiereServiceFault("Web service type " + m_webservicetype.getValue()
                        + ": reference table " + ref_id + " not found", new QName("getList"));

            MTable table = new MTable(ctx, rt.getAD_Table_ID(), null);
            MColumn column = new MColumn(ctx, rt.getAD_Key(), null);

            // TODO: if any value or identifier column is translated, then get them from trl table (and client has multilanguage documents enabled)
            sql = "SELECT " + column.getColumnName();
            listColumnNames.add(column.getColumnName());
            if (rt.isValueDisplayed()) {
                sql += ",Value";
                listColumnNames.add("Value");
            }

            String sqlident = "SELECT ColumnName FROM AD_Column WHERE AD_Table_ID=? AND IsActive='Y' AND IsIdentifier='Y' ORDER BY SeqNo";
            PreparedStatement pstmtident = null;
            ResultSet rsident = null;
            try {
                pstmtident = DB.prepareStatement(sqlident, null);
                pstmtident.setInt(1, rt.getAD_Table_ID());
                rsident = pstmtident.executeQuery();
                while (rsident.next()) {
                    String colnameident = rsident.getString("ColumnName");
                    if (rt.isValueDisplayed() && colnameident.equalsIgnoreCase("Value")) {
                        // Value already added
                    } else {
                        sql += "," + colnameident;
                        listColumnNames.add(colnameident);
                    }
                }
            } catch (Exception e) {
                // ignore this exception
            } finally {
                DB.close(rsident, pstmtident);
                rsident = null;
                pstmtident = null;
            }

            sql += " FROM " + table.getTableName() + " WHERE IsActive='Y'";
            sql = role.addAccessSQL(sql, table.getTableName(), true, true);
            sql += filter;
            if (rt.getWhereClause() != null && rt.getWhereClause().length() > 0)
                sql += " AND " + rt.getWhereClause();
            if (rt.getOrderByClause() != null && rt.getOrderByClause().length() > 0)
                sql += " ORDER BY " + rt.getOrderByClause();

            try {
                pstmt = DB.prepareStatement(sql, null);
                rs = pstmt.executeQuery();
            } catch (SQLException e) {
                res.setError(e.getMessage());
                res.setErrorInfo(sql);
                res.setSuccess(false);
                DB.close(rs, pstmt);
                rs = null;
                pstmt = null;
                throw new IdempiereServiceFault(e.getClass().toString() + " " + e.getMessage() + " sql=" + sql,
                        e.getCause(), new QName("getList"));
            }

        } else {
            // Don't fill - wrong type
        }

        if (rs != null) {
            try {
                while (rs.next()) {
                    cnt++;
                    // Add values to the dataset
                    DataRow dr = ds.addNewDataRow();
                    for (String listColumnName : listColumnNames) {
                        if (m_webservicetype.isOutputColumnNameAllowed(listColumnName)) {
                            DataField dfid = dr.addNewField();
                            dfid.setColumn(listColumnName);
                            dfid.setVal(rs.getString(listColumnName));
                        }
                    }
                }
                res.setSuccess(true);
            } catch (SQLException e) {
                res.setError(e.getMessage());
                res.setErrorInfo(sql);
                res.setSuccess(false);
                throw new IdempiereServiceFault(e.getClass().toString() + " " + e.getMessage() + " sql=" + sql,
                        e.getCause(), new QName("getList"));
            } finally {
                DB.close(rs, pstmt);
                rs = null;
                pstmt = null;
            }
        }

        res.setRowCount(cnt);
        res.setNumRows(cnt);
        res.setTotalRows(cnt);
        res.setStartRow(1);

        return resdoc;
    } finally {
        if (!connected)
            getCompiereService().disconnect();
    }
}

From source file:net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.java

protected void createStatement() throws JRException {
    String queryString = getQueryString();

    if (log.isDebugEnabled()) {
        log.debug("SQL query string: " + queryString);
    }//from w  w  w.j  a  v a  2s  . c  om

    if (connection != null && queryString != null && queryString.trim().length() > 0) {
        try {
            isProcedureCall = isProcedureCall(queryString);
            CallableStatement callableStatement = null;

            String type = getPropertiesUtil().getProperty(dataset,
                    JRJdbcQueryExecuterFactory.PROPERTY_JDBC_RESULT_SET_TYPE);
            String concurrency = getPropertiesUtil().getProperty(dataset,
                    JRJdbcQueryExecuterFactory.PROPERTY_JDBC_CONCURRENCY);
            String holdability = getPropertiesUtil().getProperty(dataset,
                    JRJdbcQueryExecuterFactory.PROPERTY_JDBC_HOLDABILITY);

            if (type == null && concurrency == null && holdability == null) {
                if (isProcedureCall) {
                    statement = callableStatement = connection.prepareCall(queryString);
                } else {
                    statement = connection.prepareStatement(queryString);
                }
            } else {
                type = type == null ? TYPE_FORWARD_ONLY : type;
                concurrency = concurrency == null ? CONCUR_READ_ONLY : concurrency;

                if (holdability == null) {
                    if (isProcedureCall) {
                        statement = callableStatement = connection.prepareCall(queryString,
                                getResultSetType(type), getConcurrency(concurrency));
                    } else {
                        statement = connection.prepareStatement(queryString, getResultSetType(type),
                                getConcurrency(concurrency));
                    }
                } else {
                    if (isProcedureCall) {
                        statement = callableStatement = connection.prepareCall(queryString,
                                getResultSetType(type), getConcurrency(concurrency),
                                getHoldability(holdability, connection));
                    } else {
                        statement = connection.prepareStatement(queryString, getResultSetType(type),
                                getConcurrency(concurrency), getHoldability(holdability, connection));
                    }
                }
            }

            int fetchSize = getPropertiesUtil().getIntegerProperty(dataset,
                    JRJdbcQueryExecuterFactory.PROPERTY_JDBC_FETCH_SIZE, 0);
            if (fetchSize != 0) {
                statement.setFetchSize(fetchSize);
            }

            int maxFieldSize = getPropertiesUtil().getIntegerProperty(dataset,
                    JRJdbcQueryExecuterFactory.PROPERTY_JDBC_MAX_FIELD_SIZE, 0);//FIXMENOW check the default of all zero default properties
            if (maxFieldSize != 0) {
                statement.setMaxFieldSize(maxFieldSize);
            }

            Integer queryTimeoutValue = getPropertiesUtil().getIntegerProperty(dataset,
                    JRJdbcQueryExecuterFactory.PROPERTY_JDBC_QUERY_TIMEOUT);
            if (queryTimeoutValue != null && queryTimeoutValue >= 0) {
                statement.setQueryTimeout(queryTimeoutValue);
            }

            Integer reportMaxCount = (Integer) getParameterValue(JRParameter.REPORT_MAX_COUNT);
            if (reportMaxCount != null) {
                statement.setMaxRows(reportMaxCount);
            }

            if (isProcedureCall) {
                initProcedureCall(callableStatement);
            }

            visitQueryParameters(new QueryParameterVisitor() {
                int paramIdx = 1;

                @Override
                public void visit(QueryParameter queryParameter) {
                    try {
                        if (queryParameter.isMulti()) {
                            paramIdx += setStatementMultiParameters(paramIdx, queryParameter.getName(),
                                    queryParameter.isIgnoreNulls());
                        } else {
                            setStatementParameter(paramIdx, queryParameter.getName());
                            ++paramIdx;
                        }
                    } catch (SQLException e) {
                        throw new VisitExceptionWrapper(e);
                    }
                }

                @Override
                public void visit(ValuedQueryParameter valuedQueryParameter) {
                    // assuming a single value for now
                    Class<?> type = valuedQueryParameter.getType();
                    Object value = valuedQueryParameter.getValue();
                    if (type == null) {
                        type = value == null ? Object.class : value.getClass();
                    }

                    if (log.isDebugEnabled()) {
                        log.debug("Parameter #" + paramIdx + " (of type " + type.getName() + "): " + value);
                    }

                    try {
                        setStatementParameter(paramIdx, type, value, dataset);// using only dataset properties for now
                        ++paramIdx;
                    } catch (SQLException e) {
                        throw new VisitExceptionWrapper(e);
                    }
                }
            });
        } catch (VisitExceptionWrapper e) {
            throw new JRException(EXCEPTION_MESSAGE_KEY_QUERY_STATEMENT_PREPARE_ERROR,
                    new Object[] { queryString }, e.getCause());
        } catch (SQLException e) {
            throw new JRException(EXCEPTION_MESSAGE_KEY_QUERY_STATEMENT_PREPARE_ERROR,
                    new Object[] { queryString }, e);
        }
    }
}

From source file:org.apache.hive.beeline.BeeLine.java

void handleSQLException(SQLException e) {
    if (e instanceof SQLWarning && !(getOpts().getShowWarnings())) {
        return;//  w w  w.j  a  v a 2 s .c o  m
    }

    if (e.getCause() instanceof TTransportException) {
        switch (((TTransportException) e.getCause()).getType()) {
        case TTransportException.ALREADY_OPEN:
            error(loc("hs2-connection-already-open"));
            break;
        case TTransportException.END_OF_FILE:
            error(loc("hs2-unexpected-end-of-file"));
            break;
        case TTransportException.NOT_OPEN:
            error(loc("hs2-could-not-open-connection"));
            break;
        case TTransportException.TIMED_OUT:
            error(loc("hs2-connection-timed-out"));
            break;
        case TTransportException.UNKNOWN:
            error(loc("hs2-unknown-connection-problem"));
            break;
        default:
            error(loc("hs2-unexpected-error"));
        }
    }

    error(loc(e instanceof SQLWarning ? "Warning" : "Error",
            new Object[] { e.getMessage() == null ? "" : e.getMessage().trim(),
                    e.getSQLState() == null ? "" : e.getSQLState().trim(), new Integer(e.getErrorCode()) }));

    if (getOpts().getVerbose()) {
        e.printStackTrace(getErrorStream());
    }

    if (!getOpts().getShowNestedErrs()) {
        return;
    }

    for (SQLException nested = e.getNextException(); nested != null
            && nested != e; nested = nested.getNextException()) {
        handleSQLException(nested);
    }
}

From source file:com.cloudant.sync.datastore.DatastoreImpl.java

@Override
public Changes changes(long since, final int limit) {
    Preconditions.checkState(this.isOpen(), "Database is closed");
    Preconditions.checkArgument(limit > 0, "Limit must be positive number");
    final long verifiedSince = since >= 0 ? since : 0;

    try {/*from   www.  j  a  v  a2  s  .  c o m*/
        return queue.submit(new SQLQueueCallable<Changes>() {
            @Override
            public Changes call(SQLDatabase db) throws Exception {
                String[] args = { Long.toString(verifiedSince), Long.toString(verifiedSince + limit) };
                Cursor cursor = null;
                try {
                    Long lastSequence = verifiedSince;
                    List<Long> ids = new ArrayList<Long>();
                    cursor = db.rawQuery(SQL_CHANGE_IDS_SINCE_LIMIT, args);
                    while (cursor.moveToNext()) {
                        ids.add(cursor.getLong(0));
                        lastSequence = Math.max(lastSequence, cursor.getLong(1));
                    }
                    List<DocumentRevision> results = getDocumentsWithInternalIdsInQueue(db, ids);
                    if (results.size() != ids.size()) {
                        throw new IllegalStateException("The number of document does not match number of ids, "
                                + "something must be wrong here.");
                    }

                    return new Changes(lastSequence, results);
                } catch (SQLException e) {
                    throw new IllegalStateException(
                            "Error querying all changes since: " + verifiedSince + ", limit: " + limit, e);
                } finally {
                    DatabaseUtils.closeCursorQuietly(cursor);
                }
            }
        }).get();
    } catch (InterruptedException e) {
        logger.log(Level.SEVERE, "Failed to get changes", e);
    } catch (ExecutionException e) {
        logger.log(Level.SEVERE, "Failed to get changes", e);
        if (e.getCause() != null) {
            if (e.getCause() instanceof IllegalStateException) {
                throw (IllegalStateException) e.getCause();
            }
        }
    }

    return null;

}

From source file:com.cloudant.sync.datastore.DatastoreImpl.java

@Override
public long getLastSequence() {
    Preconditions.checkState(this.isOpen(), "Database is closed");

    try {//from  ww w  .  j a  va2 s  . co  m

        return queue.submit(new SQLQueueCallable<Long>() {
            @Override
            public Long call(SQLDatabase db) throws Exception {
                String sql = "SELECT MAX(sequence) FROM revs";
                Cursor cursor = null;
                long result = 0;
                try {
                    cursor = db.rawQuery(sql, null);
                    if (cursor.moveToFirst()) {
                        if (cursor.columnType(0) == Cursor.FIELD_TYPE_INTEGER) {
                            result = cursor.getLong(0);
                        } else if (cursor.columnType(0) == Cursor.FIELD_TYPE_NULL) {
                            result = SEQUENCE_NUMBER_START;
                        } else {
                            throw new IllegalStateException("SQLite return an unexpected value.");
                        }
                    }
                } catch (SQLException e) {
                    logger.log(Level.SEVERE, "Error getting last sequence", e);
                    throw new DatastoreException(e);
                } finally {
                    DatabaseUtils.closeCursorQuietly(cursor);
                }
                return result;
            }
        }).get();
    } catch (InterruptedException e) {
        logger.log(Level.SEVERE, "Failed to get last Sequence", e);
        throw new RuntimeException(e);
    } catch (ExecutionException e) {
        logger.log(Level.SEVERE, "Failed to get last Sequence", e);
        if (e.getCause() != null) {
            if (e.getCause() instanceof IllegalStateException) {
                throw (IllegalStateException) e.getCause();
            }
        }
    }
    return 0;

}

From source file:edu.mit.isda.permitservice.dataobjects.HibernateAuthorizationMgr.java

/**
 * Select Qualifiers for which userName is authorized. 
 *
 * @param userName user's kerberos Id//from  w ww .j a  v  a  2 s. c  o m
 * @param function_name funtion name
 * @throws  InvalidInputException if qualifier type code is NULL or if the code is more than 4 characters long
 * @throws  ObjectNotFoundException If no Qualifier is found 
 * @throws  AuthorizationException  in case of hibernate error   
 */
public String getQualifierXML(String userName, String function_name, String qualifier_type)
        throws InvalidInputException, PermissionException, AuthorizationException {
    if (null == userName || null == function_name)
        throw new InvalidInputException();

    StringBuffer xmlBuff = new StringBuffer();
    Iterator qIt = null;
    PickableQualifier xmlqual = null;
    String pname = userName.trim().toUpperCase();
    String fname = function_name.trim().toUpperCase();
    String qtype = "ZLEVELS_" + qualifier_type.trim().toUpperCase();

    total_qualifiers = 0;

    if (pname.length() <= 0 || fname.length() <= 0)
        throw new InvalidInputException();

    HibernateTemplate t1 = getHibernateTemplate();
    Collection<LevelCount> lc = null;

    try {
        lc = t1.findByNamedQuery("GET_LEVEL_FOR_QUAL_TYPE", new String[] { qtype, qtype });
        //System.out.println(t1.toString());
        t1.initialize(lc);
    }

    catch (DataAccessException e) {
        if (e.getCause() instanceof SQLException) {
            SQLException se = (SQLException) e.getCause();
            int i = se.getErrorCode();
            String msg = se.getMessage();
            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(msg, i);

            else if (i == PermissionException.ProxyNotAuthorized
                    || i == PermissionException.ServerNotAuthorized)
                throw new PermissionException(msg, i);
            else
                throw new AuthorizationException(se.getMessage() + "\n" + "Error Code: " + se.getErrorCode()
                        + "\n" + " Cause: " + se.getCause());
        } else
            throw new AuthorizationException(e.getMessage());
    }

    int val = Integer.parseInt(lc.iterator().next().getValue()) - 1;

    HibernateTemplate t = getHibernateTemplate();
    Collection<PickableQualifier> quals = null;

    try {
        quals = t.findByNamedQuery("PICKABLE_QUALIFIER_LIST", new String[] { pname, fname });
        //System.out.println(t.toString());
        t.initialize(quals);
    }

    catch (DataAccessException e) {
        Exception re = (Exception) e.getCause();

        SQLException se = null;
        if (re instanceof org.hibernate.exception.SQLGrammarException) {
            se = ((org.hibernate.exception.SQLGrammarException) re).getSQLException();
        } else if (e.getCause() instanceof SQLException) {
            se = (SQLException) e.getCause();
        }
        if (null != se) {
            int i = se.getErrorCode();
            String msg = se.getMessage();
            String errorMessage = se.getMessage() + " Error Code: " + se.getErrorCode();

            int index = msg.indexOf("\n");
            if (index > 0)
                msg = msg.substring(0, index);
            if (i == InvalidInputException.FunctionCategoryInvalidLength
                    || i == InvalidInputException.FunctionNameInvalidLength
                    || i == InvalidInputException.NeedKerberosName
                    || i == InvalidInputException.NeedFunctionCategory
                    || i == InvalidInputException.InvalidFunction
                    || i == InvalidInputException.QualifierTypeInvalidLength)
                throw new InvalidInputException(errorMessage, i);

            else if (i == PermissionException.ProxyNotAuthorized
                    || i == PermissionException.ServerNotAuthorized)
                throw new PermissionException(errorMessage, i);
            else
                throw new AuthorizationException(errorMessage);
        } else
            throw new AuthorizationException(e.getMessage());
    }

    xmlBuff.append("<qualifiers>");

    if (quals == null)
        throw new AuthorizationException("error retrieving qualifiers for user " + userName);

    //Set<PickableQualifier> qualSet = new HashSet<PickableQualifier>(quals);
    //System.out.println(quals.size());
    //System.out.println(qualSet.size());

    //qIt = qualSet.iterator();
    qIt = quals.iterator();

    while (qIt.hasNext()) {
        total_qualifiers++;
        //System.out.println("Total = " + total_qualifiers);
        xmlqual = (PickableQualifier) qIt.next();
        xmlBuff.append("<qualifier>");
        xmlBuff.append("<qid>");
        xmlBuff.append(xmlqual.getId().getId());
        xmlBuff.append("</qid>");
        xmlBuff.append("<expanded>");
        xmlBuff.append("true");
        xmlBuff.append("</expanded>");
        xmlBuff.append("<qcode>");
        xmlBuff.append(cleanup(xmlqual.getQcode(), false));
        xmlBuff.append("</qcode>");
        xmlBuff.append("<qname>");
        xmlBuff.append(cleanup(xmlqual.getId().getName(), false));
        xmlBuff.append("</qname>");
        xmlBuff.append("<hasChild>");
        xmlBuff.append(cleanup(xmlqual.getId().getHasChild().toString(), false));
        xmlBuff.append("</hasChild>");
        if (xmlqual.getId().getHasChild() && total_qualifiers < 2000) {
            xmlBuff.append("<qchildren>");
            xmlBuff.append(getChildrenXML(xmlqual.getId().getId().toString(), 1, val));
            xmlBuff.append("</qchildren>");
        }
        xmlBuff.append("</qualifier>");
    }

    xmlBuff.append("</qualifiers>");
    //System.out.println("Final Buffer = " + xmlBuff.toString());
    return xmlBuff.toString();
}

From source file:org.ow2.bonita.persistence.db.DbSessionImpl.java

private String getSqlState(final SQLException e) {
    String sqlState = e.getSQLState();
    if (sqlState == null) {
        if (e.getCause() != null) {
            final SQLException nextException = e.getNextException();
            if (nextException != null) {
                sqlState = nextException.getSQLState();
            }/*from www.  ja v  a  2s. co  m*/
        }
    }
    return sqlState;
}