Example usage for java.sql ResultSet CONCUR_READ_ONLY

List of usage examples for java.sql ResultSet CONCUR_READ_ONLY

Introduction

In this page you can find the example usage for java.sql ResultSet CONCUR_READ_ONLY.

Prototype

int CONCUR_READ_ONLY

To view the source code for java.sql ResultSet CONCUR_READ_ONLY.

Click Source Link

Document

The constant indicating the concurrency mode for a ResultSet object that may NOT be updated.

Usage

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BoolDefTable.java

public MSSBamBoolDefBuff[] readBuffByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) {
    final String S_ProcName = "readBuffByScopeIdx";
    try {//from   www .  ja va  2  s. c  o m
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectBoolDefBuff + "WHERE "
                + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ")
                + "ORDER BY " + "anyo.Id ASC";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        List<MSSBamBoolDefBuff> buffList = new ArrayList<MSSBamBoolDefBuff>();
        while (resultSet.next()) {
            MSSBamBoolDefBuff buff = unpackBoolDefResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        return (buffList.toArray(new MSSBamBoolDefBuff[0]));
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BlobDefTable.java

public MSSBamBlobDefBuff[] readBuffByTenantIdx(MSSBamAuthorization Authorization, long TenantId) {
    final String S_ProcName = "readBuffByTenantIdx";
    try {//  www  .  j  ava2s . c o  m
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectBlobDefBuff + "WHERE " + "anyo.TenantId = " + Long.toString(TenantId) + " "
                + "ORDER BY " + "anyo.Id ASC";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        List<MSSBamBlobDefBuff> buffList = new ArrayList<MSSBamBlobDefBuff>();
        while (resultSet.next()) {
            MSSBamBlobDefBuff buff = unpackBlobDefResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        return (buffList.toArray(new MSSBamBlobDefBuff[0]));
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BoolDefTable.java

public MSSBamBoolDefBuff[] readBuffByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) {
    final String S_ProcName = "readBuffByAuthorIdx";
    try {//from   ww  w .jav  a2 s.c o m
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectBoolDefBuff + "WHERE " + ((AuthorId == null) ? "anyo.AuthorId is null "
                : "anyo.AuthorId = " + AuthorId.toString() + " ") + "ORDER BY " + "anyo.Id ASC";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        List<MSSBamBoolDefBuff> buffList = new ArrayList<MSSBamBoolDefBuff>();
        while (resultSet.next()) {
            MSSBamBoolDefBuff buff = unpackBoolDefResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        return (buffList.toArray(new MSSBamBoolDefBuff[0]));
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BlobDefTable.java

public MSSBamBlobDefBuff[] readBuffByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) {
    final String S_ProcName = "readBuffByScopeIdx";
    try {/*from w  w w  .java  2  s. c om*/
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectBlobDefBuff + "WHERE "
                + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ")
                + "ORDER BY " + "anyo.Id ASC";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        List<MSSBamBlobDefBuff> buffList = new ArrayList<MSSBamBlobDefBuff>();
        while (resultSet.next()) {
            MSSBamBlobDefBuff buff = unpackBlobDefResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        return (buffList.toArray(new MSSBamBlobDefBuff[0]));
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:edu.ku.brc.specify.conversion.BasicSQLUtils.java

/**
 * @param fromConn//  w ww. j  a v a  2s  . c o  m
 * @param toConn
 * @param sql
 * @param fromTableName
 * @param toTableName
 * @param colNewToOldMap
 * @param verbatimDateMapper
 * @param newColDefValues
 * @param sourceServerType
 * @param destServerType
 * @return
 */
public static boolean copyTable(final Connection fromConn, final Connection toConn, final String sql,
        final String countSQL, final String fromTableName, final String toTableName,
        final Map<String, String> colNewToOldMap, final Map<String, String> verbatimDateMapper,
        final Map<String, String> newColDefValues, final SERVERTYPE sourceServerType,
        final SERVERTYPE destServerType) {
    //Timestamp now = new Timestamp(System.currentTimeMillis());

    IdMapperMgr idMapperMgr = IdMapperMgr.getInstance();

    if (frame != null) {
        frame.setDesc("Copying Table " + fromTableName);
    }
    log.info("Copying Table " + fromTableName);

    List<String> fromFieldNameList = getFieldNamesFromSchema(fromConn, fromTableName);

    String sqlStr = sql + " ORDER BY " + fromTableName + "." + fromFieldNameList.get(0);
    log.debug(sqlStr);

    int numRecs;
    if (countSQL == null) {
        numRecs = getNumRecords(fromConn, fromTableName);
    } else {
        numRecs = getCountAsInt(fromConn, countSQL);
    }
    setProcess(0, numRecs);

    DBTableInfo tblInfo = DBTableIdMgr.getInstance().getInfoByTableName(toTableName);
    Statement updateStatement = null;
    String id = "";
    try {

        updateStatement = toConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        if (BasicSQLUtils.myDestinationServerType != BasicSQLUtils.SERVERTYPE.MS_SQLServer) {
            BasicSQLUtils.removeForeignKeyConstraints(toConn, BasicSQLUtils.myDestinationServerType);

        }

        //HashMap<String, Integer> newDBFieldHash   = new HashMap<String, Integer>();
        List<FieldMetaData> newFieldMetaData = getFieldMetaDataFromSchema(toConn, toTableName);
        //int inx = 1;
        //for (FieldMetaData fmd : newFieldMetaData)
        //{
        //    newDBFieldHash.put(fmd.getName(), inx++);
        //}

        Statement stmt = fromConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        //System.out.println(sqlStr);
        ResultSet rs = stmt.executeQuery(sqlStr);
        ResultSetMetaData rsmd = rs.getMetaData();

        Vector<Integer> dateColumns = new Vector<Integer>();

        //System.out.println(toTableName);
        Hashtable<String, Integer> fromHash = new Hashtable<String, Integer>();
        for (int i = 1; i <= rsmd.getColumnCount(); i++) {
            String colName = rsmd.getColumnName(i);

            fromHash.put(colName, i);
            //System.out.println(rsmd.getColumnName(i)+" -> "+i);

            if (rsmd.getColumnType(i) == java.sql.Types.DATE || colName.toLowerCase().endsWith("date")
                    || colName.toLowerCase().startsWith("date")) {
                //System.out.println("Date: "+rsmd.getColumnName(i)+" -> "+i);
                dateColumns.add(i);
            }
        }

        Hashtable<String, String> oldNameToNewNameHash = new Hashtable<String, String>();
        if (colNewToOldMap != null) {
            for (String newName : colNewToOldMap.keySet()) {
                String oldName = colNewToOldMap.get(newName);
                System.out
                        .println("Mapping oldName[" + (oldName == null ? newName : oldName) + " -> " + newName);

                oldNameToNewNameHash.put(oldName == null ? newName : oldName, newName);
            }
        }

        // System.out.println("Num Cols: "+rsmd.getColumnCount());

        Map<String, PartialDateConv> dateMap = new Hashtable<String, PartialDateConv>();

        String insertSQL = null;

        // Get the columns that have dates in case we get a TimestampCreated date that is null
        // and then we can go looking for an older date to try to figure it out
        Integer timestampModifiedInx = fromHash.get("TimestampModified");
        Integer timestampCreatedInx = fromHash.get("TimestampCreated");
        boolean isAccessionTable = fromTableName.equals("accession");
        boolean hasInstIdCol = fromTableName.equals("permit") || fromTableName.equals("journal")
                || fromTableName.equals("referencework");

        StringBuffer str = new StringBuffer(1024);
        int count = 0;
        while (rs.next()) {
            boolean skipRecord = false;

            dateMap.clear();

            // Start by going through the resultset and converting all dates from Integers
            // to real dates and keep the verbatium date information if it is a partial date
            for (int i : dateColumns) {
                String oldColName = rsmd.getColumnName(i);
                Integer oldColIndex = fromHash.get(oldColName);

                if (oldColIndex == null) {
                    log.error("Couldn't find new column for old column for date for Table[" + fromTableName
                            + "] Col Name[" + newFieldMetaData.get(i).getName() + "]");
                    continue;
                }

                if (oldColIndex > newFieldMetaData.size()) {
                    continue;
                }

                String newColName = colNewToOldMap != null ? oldNameToNewNameHash.get(oldColName) : null;
                if (newColName == null) {
                    newColName = oldColName;
                }

                Object dataObj = rs.getObject(i);

                if (dataObj instanceof Integer) {
                    PartialDateConv datep = new PartialDateConv();
                    getPartialDate((Integer) dataObj, datep); // fills in Verbatim also

                    dateMap.put(newColName, datep);
                }
            }

            // OK here we make sure that both the created dated ad modified date are not null
            // and we copy the date if one has a value and the other does not.
            Date timestampCreatedCached = now;
            Date timestampModifiedCached = now;

            if (timestampModifiedInx != null && timestampCreatedInx != null) {
                timestampModifiedCached = rs.getDate(timestampModifiedInx);
                timestampCreatedCached = rs.getDate(timestampCreatedInx);
                if (timestampModifiedCached == null && timestampCreatedCached == null) {
                    timestampCreatedCached = Calendar.getInstance().getTime();
                    timestampModifiedCached = Calendar.getInstance().getTime();

                } else if (timestampModifiedCached == null && timestampCreatedCached != null) {
                    timestampModifiedCached = new Date(timestampCreatedCached.getTime());
                } else {
                    timestampCreatedCached = timestampModifiedCached != null
                            ? new Date(timestampModifiedCached.getTime())
                            : new Date();
                }
            } else {

                if (timestampModifiedInx != null) {
                    timestampModifiedCached = rs.getDate(timestampModifiedInx);
                    if (timestampModifiedCached == null) {
                        timestampModifiedCached = now;
                    }
                }

                if (timestampCreatedInx != null) {
                    timestampCreatedCached = rs.getDate(timestampCreatedInx);
                    if (timestampCreatedCached == null) {
                        timestampCreatedCached = now;
                    }
                }
            }

            str.setLength(0);
            if (insertSQL == null) {
                StringBuffer fieldList = new StringBuffer();
                fieldList.append("( ");
                for (int i = 0; i < newFieldMetaData.size(); i++) {
                    if ((i > 0) && (i < newFieldMetaData.size())) {
                        fieldList.append(", ");
                    }
                    String newFieldName = newFieldMetaData.get(i).getName();
                    fieldList.append(newFieldName + " ");
                }
                fieldList.append(")");

                str.append("INSERT INTO " + toTableName + " " + fieldList + " VALUES (");

                insertSQL = str.toString();

                log.debug(str);
            } else {
                str.append(insertSQL);
            }

            id = rs.getString(1);

            // For each column in the new DB table...
            for (int i = 0; i < newFieldMetaData.size(); i++) {
                FieldMetaData newFldMetaData = newFieldMetaData.get(i);
                String newColName = newFldMetaData.getName();
                String oldMappedColName = null;

                //System.out.println("["+newColName+"]");

                // Get the Old Column Index from the New Name
                // String  oldName     = colNewToOldMap != null ? colNewToOldMap.get(newColName) : newColName;
                Integer columnIndex = fromHash.get(newColName);

                if (columnIndex == null && colNewToOldMap != null) {
                    oldMappedColName = colNewToOldMap.get(newColName);
                    if (oldMappedColName != null) {
                        columnIndex = fromHash.get(oldMappedColName);

                    } else if (isOptionOn(SHOW_NAME_MAPPING_ERROR) && (ignoreMappingFieldNames == null
                            || ignoreMappingFieldNames.get(newColName) == null)) {
                        String msg = "No Map for table [" + fromTableName + "] from New Name[" + newColName
                                + "] to Old Name[" + oldMappedColName + "]";
                        log.error(msg);

                        writeErrLog(msg);

                    }
                } else {
                    oldMappedColName = newColName;
                }

                String verbatimDateFieldName = null;
                if (verbatimDateMapper != null) {
                    verbatimDateFieldName = verbatimDateMapper.get(newColName);
                }

                //System.out.println("new["+newColName+"]  old["+oldMappedColName+"]");

                if (columnIndex != null) {
                    if (i > 0)
                        str.append(", ");
                    Object dataObj = rs.getObject(columnIndex);

                    if (idMapperMgr != null && oldMappedColName != null && oldMappedColName.endsWith("ID")) {
                        IdMapperIFace idMapper = idMapperMgr.get(fromTableName, oldMappedColName);
                        if (idMapper != null) {
                            int showNullOption = SHOW_NULL_FK;
                            int showFkLookUpOption = SHOW_FK_LOOKUP;

                            int oldPrimaryKeyId = rs.getInt(columnIndex);
                            if (oldMappedColName.equalsIgnoreCase(fromTableName + "id")) {
                                showNullOption = SHOW_NULL_PM;
                                showFkLookUpOption = SHOW_PM_LOOKUP;
                            }

                            // if the value was null, getInt() returns 0
                            // use wasNull() to distinguish real 0 from a null return
                            if (rs.wasNull()) {
                                dataObj = null;

                                if (isOptionOn(showNullOption)) {

                                    String msg = "Unable to Map "
                                            + (showNullOption == SHOW_NULL_FK ? "Foreign" : "Primary")
                                            + " Key Id[NULL] old Name[" + oldMappedColName + "]   colInx["
                                            + columnIndex + "]   newColName[" + newColName + "]";
                                    log.error(msg);
                                    writeErrLog(msg);
                                    skipRecord = true;
                                }
                            } else {
                                dataObj = idMapper.get(oldPrimaryKeyId);

                                if (dataObj == null && isOptionOn(showFkLookUpOption)) {
                                    String msg = "Unable to Map Primary Id[" + oldPrimaryKeyId + "] old Name["
                                            + oldMappedColName + "] table[" + fromTableName + "]";
                                    log.error(msg);
                                    writeErrLog(msg);
                                    skipRecord = true;
                                }
                            }
                        } else {
                            if (isOptionOn(SHOW_NAME_MAPPING_ERROR) && (ignoreMappingFieldIDs == null
                                    || ignoreMappingFieldIDs.get(oldMappedColName) == null)) {
                                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                                // XXX Temporary fix so it doesn't hide other errors
                                // Josh has promised his first born if he doesn't fix this!
                                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                                if (!oldMappedColName.equals("RankID")) {
                                    //idMapperMgr.dumpKeys();
                                    String msg = "No ID Map for [" + fromTableName + "] Old Column Name["
                                            + oldMappedColName + "]";
                                    log.error(msg);
                                    writeErrLog(msg);
                                    skipRecord = true;
                                }
                            }
                        }
                    }

                    // First check to see if it is null
                    if (dataObj == null) {
                        if (newFldMetaData.getName().equals("TimestampCreated")) {
                            if (timestampCreatedInx != null) {
                                if (isAccessionTable) {
                                    Date date = UIHelper
                                            .convertIntToDate(rs.getInt(fromHash.get("DateAccessioned")));
                                    str.append(date != null ? getStrValue(date)
                                            : getStrValue(timestampCreatedCached, newFldMetaData.getType()));
                                } else {
                                    str.append(getStrValue(timestampCreatedCached, newFldMetaData.getType()));
                                }

                            } else {
                                str.append(getStrValue(timestampCreatedCached, newFldMetaData.getType()));
                            }

                        } else if (newFldMetaData.getName().equals("TimestampModified")) {
                            if (timestampModifiedInx != null) {
                                if (isAccessionTable) {
                                    Date date = UIHelper
                                            .convertIntToDate(rs.getInt(fromHash.get("DateAccessioned")));
                                    str.append(date != null ? getStrValue(date)
                                            : getStrValue(timestampCreatedCached, newFldMetaData.getType()));

                                } else {
                                    str.append(getStrValue(timestampModifiedCached, newFldMetaData.getType()));
                                }
                            } else {
                                str.append(getStrValue(timestampModifiedCached, newFldMetaData.getType()));
                            }
                        } else {
                            str.append("NULL");
                        }

                    } else if (dataObj instanceof Integer && (newFldMetaData.getSqlType() == java.sql.Types.DATE
                            || newColName.toLowerCase().endsWith("date")
                            || newColName.toLowerCase().startsWith("date"))) {
                        PartialDateConv datePr = dateMap.get(newColName);
                        if (datePr != null) {
                            str.append(datePr.getDateStr());
                        } else {
                            str.append("NULL");
                        }

                    } else if (verbatimDateFieldName != null) {
                        PartialDateConv datePr = dateMap.get(newColName);
                        str.append(datePr != null ? datePr.getVerbatim() : "NULL");

                    } else if (dataObj instanceof Number) {
                        DBFieldInfo fi = tblInfo.getFieldByColumnName(newColName);
                        String type = newFldMetaData.getType().toLowerCase().startsWith("tiny") ? fi.getType()
                                : newFldMetaData.getType();
                        str.append(getStrValue(dataObj, type));

                    } else {
                        if (columnValueMapper != null) {
                            BasicSQLUtilsMapValueIFace valueMapper = columnValueMapper.get(newColName);
                            if (valueMapper != null) {
                                dataObj = valueMapper.mapValue(dataObj);
                            }
                        }

                        if (dataObj instanceof String && newFldMetaData.isString()) {
                            DBFieldInfo fi = tblInfo.getFieldByColumnName(newColName);
                            String s = (String) dataObj;
                            if (s.length() > fi.getLength()) {
                                String msg = String.format(
                                        "Truncating Table '%s' Field '%s' with Length %d, db len %d Value[%s]",
                                        toTableName, newColName, s.length(), fi.getLength(), s);
                                tblWriter.logError(msg);
                                log.error(msg);
                                dataObj = s.substring(0, fi.getLength());
                            }
                        }
                        str.append(getStrValue(dataObj, newFldMetaData.getType()));
                    }

                } else if (hasInstIdCol && newFldMetaData.getName().equals("InstitutionID")) {
                    if (i > 0)
                        str.append(", ");
                    str.append("1");

                } else if (newColName.endsWith("Version")) {
                    if (i > 0)
                        str.append(", ");
                    str.append("0");

                } else if (newColName.endsWith("DatePrecision")) {
                    if (i > 0)
                        str.append(", ");

                    String cName = newColName.substring(0, newColName.length() - 9);
                    PartialDateConv datePr = dateMap.get(cName);
                    if (datePr != null) {
                        str.append(datePr.getPartial());
                    } else {
                        str.append("NULL");
                    }

                } else if (idMapperMgr != null && newColName.endsWith("ID") && oneToOneIDHash != null
                        && oneToOneIDHash.get(newColName) != null) {

                    IdMapperIFace idMapper = idMapperMgr.get(toTableName, newColName);
                    if (idMapper != null) {
                        idMapper.setShowLogErrors(false);
                        Integer newPrimaryId = idMapper.get(Integer.parseInt(id));
                        if (newPrimaryId != null) {
                            if (i > 0)
                                str.append(", ");
                            str.append(newPrimaryId);
                        } else {
                            if (i > 0)
                                str.append(", ");
                            str.append("NULL");

                            if (isOptionOn(SHOW_VAL_MAPPING_ERROR)) {
                                String msg = "For Table[" + fromTableName + "] mapping new Column Name["
                                        + newColName + "] ID[" + id + "] was not mapped";
                                log.error(msg);
                                writeErrLog(msg);
                                skipRecord = true;
                            }
                        }
                    }

                } else // there was no old column that maps to this new column
                {
                    String newColValue = null;
                    if (newColDefValues != null) {
                        newColValue = newColDefValues.get(newColName);
                    }

                    if (newColValue == null) {
                        newColValue = "NULL";
                        //System.out.println("ignoreMappingFieldNames" + ignoreMappingFieldNames);
                        //System.out.println("ignoreMappingFieldNames.get(colName)" + ignoreMappingFieldNames.get(colName));
                        if (isOptionOn(SHOW_NAME_MAPPING_ERROR) && (ignoreMappingFieldNames == null
                                || ignoreMappingFieldNames.get(newColName) == null)) {
                            String msg = "For Table[" + fromTableName + "] mapping new Column Name["
                                    + newColName + "] was not mapped";
                            log.error(msg);
                            writeErrLog(msg);
                            skipRecord = true;
                        }
                    }
                    if (i > 0)
                        str.append(", ");

                    BasicSQLUtilsMapValueIFace valueMapper = columnValueMapper.get(newFldMetaData.getName());
                    if (valueMapper != null) {
                        newColValue = valueMapper.mapValue(newColValue);
                    }

                    str.append(newColValue);
                }

            }

            str.append(")");
            if (frame != null) {
                if (count % 500 == 0) {
                    frame.setProcess(count);
                }

            } else {
                if (count % 2000 == 0) {
                    log.info(toTableName + " processed: " + count);
                }
            }

            //setQuotedIdentifierOFFForSQLServer(toConn, BasicSQLUtils.myDestinationServerType);
            //exeUpdateCmd(updateStatement, "SET FOREIGN_KEY_CHECKS = 0");
            //if (str.toString().toLowerCase().contains("insert into locality"))
            //{
            //log.debug(str.toString());
            //}

            //String str2 = "SET QUOTED_IDENTIFIER ON";
            //log.debug("executing: " + str);
            //updateStatement.execute(str2);
            // updateStatement.close();
            if (!skipRecord) {
                if (isOptionOn(SHOW_COPY_TABLE)) {
                    log.debug("executing: " + str);
                }
                int retVal = exeUpdateCmd(updateStatement, str.toString());
                if (retVal == -1) {
                    rs.close();
                    stmt.clearBatch();
                    stmt.close();
                    return false;
                }
            }
            count++;
            // if (count == 1) break;
        }

        if (frame != null) {
            frame.setProcess(count);

        } else {
            log.info(fromTableName + " processed " + count + " records.");
        }

        rs.close();
        stmt.clearBatch();
        stmt.close();

    } catch (SQLException ex) {
        ex.printStackTrace();

        edu.ku.brc.af.core.UsageTracker.incrSQLUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BasicSQLUtils.class, ex);
        //e.printStackTrace();
        log.error(sqlStr);
        log.error(ex);
        log.error("ID: " + id);
    } finally {
        try {
            updateStatement.clearBatch();
            updateStatement.close();

        } catch (SQLException ex) {

        }
    }
    BasicSQLUtils.setFieldsToIgnoreWhenMappingNames(null);//meg added
    return true;
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BoolDefTable.java

public MSSBamBoolDefBuff readBuffByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) {
    final String S_ProcName = "readBuffByUNameIdx";
    try {//from   ww w . ja  v  a  2 s  . com
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectBoolDefBuff + "WHERE "
                + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ")
                + "AND " + "anyo.Name = " + MSSBamPg8Schema.getQuotedString(Name) + " ";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        if (resultSet.next()) {
            MSSBamBoolDefBuff buff = unpackBoolDefResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected");
            }
            return (buff);
        } else {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BlobDefTable.java

public MSSBamBlobDefBuff[] readBuffByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) {
    final String S_ProcName = "readBuffByAuthorIdx";
    try {//from  www  .jav  a 2 s.co  m
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectBlobDefBuff + "WHERE " + ((AuthorId == null) ? "anyo.AuthorId is null "
                : "anyo.AuthorId = " + AuthorId.toString() + " ") + "ORDER BY " + "anyo.Id ASC";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        List<MSSBamBlobDefBuff> buffList = new ArrayList<MSSBamBlobDefBuff>();
        while (resultSet.next()) {
            MSSBamBlobDefBuff buff = unpackBlobDefResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        return (buffList.toArray(new MSSBamBlobDefBuff[0]));
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BlobDefTable.java

public MSSBamBlobDefBuff readBuffByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) {
    final String S_ProcName = "readBuffByUNameIdx";
    try {/*from w  w  w.  j  av a  2  s  .co m*/
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectBlobDefBuff + "WHERE "
                + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ")
                + "AND " + "anyo.Name = " + MSSBamPg8Schema.getQuotedString(Name) + " ";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        if (resultSet.next()) {
            MSSBamBlobDefBuff buff = unpackBlobDefResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected");
            }
            return (buff);
        } else {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BoolDefTable.java

public MSSBamBoolDefBuff[] readBuffByVContIdx(MSSBamAuthorization Authorization, long ValueContainerId) {
    final String S_ProcName = "readBuffByVContIdx";
    try {//from   w w w  . j av  a2 s. c  o m
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectBoolDefBuff + "WHERE " + "val.ValueContainerId = "
                + Long.toString(ValueContainerId) + " " + "ORDER BY " + "anyo.Id ASC";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        List<MSSBamBoolDefBuff> buffList = new ArrayList<MSSBamBoolDefBuff>();
        while (resultSet.next()) {
            MSSBamBoolDefBuff buff = unpackBoolDefResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        return (buffList.toArray(new MSSBamBoolDefBuff[0]));
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BoolDefTable.java

public MSSBamBoolDefBuff[] readBuffByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) {
    final String S_ProcName = "readBuffByDataScopeIdx";
    try {/*from   w  w w . j  a  v a2s  . c  om*/
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectBoolDefBuff + "WHERE " + ((DataScopeId == null) ? "val.DataScopeId is null "
                : "val.DataScopeId = " + DataScopeId.toString() + " ") + "ORDER BY " + "anyo.Id ASC";
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        List<MSSBamBoolDefBuff> buffList = new ArrayList<MSSBamBoolDefBuff>();
        while (resultSet.next()) {
            MSSBamBoolDefBuff buff = unpackBoolDefResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        return (buffList.toArray(new MSSBamBoolDefBuff[0]));
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}