Example usage for java.sql Types VARCHAR

List of usage examples for java.sql Types VARCHAR

Introduction

In this page you can find the example usage for java.sql Types VARCHAR.

Prototype

int VARCHAR

To view the source code for java.sql Types VARCHAR.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARCHAR.

Usage

From source file:edu.harvard.i2b2.crc.dao.setfinder.QueryResultInstanceSpringDao.java

/**
 * Function used to update result instance description
 * //from   w w  w  .  ja va  2s.  co m
 * @param resultInstanceId
 * @param description
 */
public void updateResultInstanceDescription(String resultInstanceId, String description) {
    String sql = "update " + getDbSchemaName()
            + "qt_query_result_instance set description = ?  where result_instance_id = ?";
    jdbcTemplate.update(sql, new Object[] { description, Integer.parseInt(resultInstanceId) },
            new int[] { Types.VARCHAR, Types.INTEGER });
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstOracle.CFAstOracleSecDeviceTable.java

public void createSecDevice(CFAstAuthorization Authorization, CFAstSecDeviceBuff Buff) {
    final String S_ProcName = "createSecDevice";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//  www.java 2s  .  c  o  m
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        UUID SecUserId = Buff.getRequiredSecUserId();
        String DevName = Buff.getRequiredDevName();
        String PubKey = Buff.getOptionalPubKey();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".crt_secdev( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, "SDEV");
        stmtCreateByPKey.setString(argIdx++, SecUserId.toString());
        stmtCreateByPKey.setString(argIdx++, DevName);
        if (PubKey != null) {
            stmtCreateByPKey.setString(argIdx++, PubKey);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.execute();
        resultSet = (ResultSet) stmtCreateByPKey.getObject(1);
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "crt_secdev() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAstSecDeviceBuff createdBuff = unpackSecDeviceResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId());
                Buff.setRequiredDevName(createdBuff.getRequiredDevName());
                Buff.setOptionalPubKey(createdBuff.getOptionalPubKey());
                Buff.setRequiredRevision(createdBuff.getRequiredRevision());
                Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
                Buff.setCreatedAt(createdBuff.getCreatedAt());
                Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
                Buff.setUpdatedAt(createdBuff.getUpdatedAt());
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Expected a single-record response, " + resultSet.getRow() + " rows selected");
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "crt_secdev() did not return a valid result set");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtCreateByPKey != null) {
            try {
                stmtCreateByPKey.close();
            } catch (SQLException e) {
            }
            stmtCreateByPKey = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMSSql.CFEnSyntaxMSSqlSecDeviceTable.java

public void createSecDevice(CFEnSyntaxAuthorization Authorization, CFEnSyntaxSecDeviceBuff Buff) {
    final String S_ProcName = "createSecDevice";
    if ("SDEV".equals(Buff.getClassCode()) && (!schema.isSystemUser(Authorization))) {
        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                "Permission denied -- only system user can modify SecDevice data");
    }/*w  w w  .  j a va  2  s.co m*/
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }
    try {
        Connection cnx = schema.getCnx();
        UUID SecUserId = Buff.getRequiredSecUserId();
        String DevName = Buff.getRequiredDevName();
        String PubKey = Buff.getOptionalPubKey();
        int Revision = 1;
        String sql = "INSERT INTO " + schema.getLowerDbSchemaName() + "..SecDev( " + "forcesynclock, "
                + "createdby, " + "createdat, " + "updatedby, " + "updatedat, " + "secuserid, " + "devname, "
                + "pubkey" + ", revision )" + "VALUES ( " + "0, " + " ?, " + " getdate(), " + " ?, "
                + " getdate(), " + "?" + ", " + "?" + ", " + "?" + ", " + "1 )";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setString(argIdx++, Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++, Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++, SecUserId.toString());
        stmtCreateByPKey.setString(argIdx++, DevName);
        if (PubKey != null) {
            stmtCreateByPKey.setString(argIdx++, PubKey);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        int rowsAffected = stmtCreateByPKey.executeUpdate();
        if (rowsAffected != 1) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 row to be affected by insert, not " + rowsAffected);
        }
        Buff.setRequiredRevision(Revision);
        String sqlAuditCreated = "INSERT INTO " + schema.getLowerDbSchemaName() + "..SecDev_h( auditclusterid, "
                + " auditsessionid, " + " auditstamp" + ", " + "secuserid" + ", " + "devname" + ", " + "pubkey"
                + ", " + " revision, " + " auditaction ) " + "SELECT ?, ?, sysdatetime()" + ", "
                + "sdev.secuserid" + ", " + "sdev.devname" + ", " + "sdev.pubkey" + ", " + " sdev.revision, "
                + " 1" + "FROM " + schema.getLowerDbSchemaName() + "..SecDev AS sdev " + " WHERE "
                + "sdev.secuserid = ? " + "AND sdev.devname = ? ";
        if (stmtAuditCreatedByPKey == null) {
            stmtAuditCreatedByPKey = cnx.prepareStatement(sqlAuditCreated);
        }
        argIdx = 1;
        stmtAuditCreatedByPKey.setLong(argIdx++, Authorization.getSecClusterId());
        stmtAuditCreatedByPKey.setString(argIdx++, Authorization.getSecSessionId().toString());
        stmtAuditCreatedByPKey.setString(argIdx++, SecUserId.toString());
        stmtAuditCreatedByPKey.setString(argIdx++, DevName);
        int rowsAudited = stmtAuditCreatedByPKey.executeUpdate();
        if (rowsAudited != 1) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 row to be affected by audit via insert-selected, not " + rowsAffected);
        }

    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseDomainTable.java

public void createDomain(CFSecurityAuthorization Authorization, CFInternetDomainBuff Buff) {
    final String S_ProcName = "createDomain";
    ResultSet resultSet = null;//from w w  w  . ja  va 2 s . c o  m
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getOptionalDescription();
        long SubDomainOfId = Buff.getRequiredSubDomainOfId();
        String Name = Buff.getRequiredName();
        Connection cnx = schema.getCnx();
        String sql = "exec sp_create_domdef ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, ClassCode);
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        if (Description != null) {
            stmtCreateByPKey.setString(argIdx++, Description);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.setLong(argIdx++, SubDomainOfId);
        stmtCreateByPKey.setString(argIdx++, Name);
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFInternetDomainBuff createdBuff = unpackDomainResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredId(createdBuff.getRequiredId());
            Buff.setOptionalDescription(createdBuff.getOptionalDescription());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
            Buff.setCreatedAt(createdBuff.getCreatedAt());
            Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
            Buff.setUpdatedAt(createdBuff.getUpdatedAt());
            Buff.setRequiredSubDomainOfId(createdBuff.getRequiredSubDomainOfId());
            Buff.setRequiredName(createdBuff.getRequiredName());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:madgik.exareme.master.queryProcessor.analyzer.stat.ExternalStat.java

@Override
public Map<String, Table> extractStats() throws Exception {

    DatabaseMetaData dbmd = con.getMetaData(); // dtabase metadata object

    // listing tables and columns
    String catalog = null;/*from  w ww  .ja v a2  s  .co  m*/
    String schemaPattern = sch;
    String tableNamePattern = tblName;
    String columnNamePattern = "%";
    if (con.getClass().getName().contains("postgresql")) {
        // tableNamePattern="\""+tableNamePattern+"\"";
        schemaPattern = "public";
    }

    // ResultSet resultTables = dbmd.getTables(catalog, "public",
    // tableNamePattern, types);
    ResultSet resultColumns = dbmd.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern);
    if (con.getClass().getName().contains("postgresql")) {
        tableNamePattern = "\"" + tableNamePattern + "\"";
    } else if (con.getClass().getName().contains("oracle")) {
        tableNamePattern = schemaPattern + "." + tableNamePattern;
    }
    log.debug("Starting extracting stats");
    // while (resultTables.next()) {
    Map<String, Column> columnMap = new HashMap<String, Column>();
    // StringEscapeUtils.escapeJava(resultTables.getString(3));
    log.debug("Analyzing table " + tblName);

    int toupleSize = 0; // in bytes

    // tableNamePattern = tableName;

    int columnCount = resultColumns.getMetaData().getColumnCount();
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery("select count(*) from " + tableNamePattern);
    int count = 0;
    if (rs.next()) {
        count = rs.getInt(1);
    } else {
        log.error("could not get count for table " + tableNamePattern);
    }
    rs.close();
    st.close();

    ResultSet pkrs = dbmd.getExportedKeys("", "", tblName);
    String pkey = "DEFAULT_KEY";

    while (pkrs.next()) {
        pkey = pkrs.getString("PKCOLUMN_NAME");
        break;
    }
    pkrs.close();
    if (count == 0) {
        log.debug("Empty table");
        Table t = new Table(tblName, columnCount, toupleSize, columnMap, count, pkey);
        schema.put(tblName, t);
        return schema;
    }

    while (resultColumns.next()) {

        String columnName = StringEscapeUtils.escapeJava(resultColumns.getString(4));
        try {
            String colNamePattern = columnName;
            if (con.getClass().getName().contains("postgresql")) {
                colNamePattern = "\"" + columnName + "\"";
            }
            int columnType = resultColumns.getInt(5);

            // computing column's size in bytes
            int columnSize = computeColumnSize(colNamePattern, columnType, tableNamePattern);
            toupleSize += columnSize;

            // execute queries for numberOfDiffValues, minVal, maxVal
            // Map<String, Integer> diffValFreqMap = new HashMap<String,
            // Integer>();

            // computing column's min and max values
            String minVal = "0";
            String maxVal = "0";
            if (columnType != Types.BLOB) {
                MinMax mm = computeMinMax(tableNamePattern, colNamePattern);
                minVal = mm.getMin();
                maxVal = mm.getMax();
            }
            Map<String, Integer> diffValFreqMap = new HashMap<String, Integer>();
            //only for equidepth!

            // for (ValFreq k : freqs) {
            // diffValFreqMap.put(k.getVal(), k.getFreq());

            // }

            // /add min max diff vals in the sampling values

            int minOcc = 1;
            int maxOcc = 1;
            int diffVals = 0;
            boolean equidepth = false;
            if (equidepth) {

                //diffValFreqMap is used only in equidepth, do not compute it
                //if we have primitive
                diffValFreqMap = computeDistinctValuesFrequency(tableNamePattern, colNamePattern);

                String minValChar = minVal;
                String maxValChar = maxVal;
                if (columnType == Types.VARCHAR || columnType == Types.CHAR || columnType == Types.LONGNVARCHAR
                        || columnType == Types.DATE) {
                    minValChar = "\'" + minVal + "\'";
                    maxValChar = "\'" + maxVal + "\'";
                }
                try {
                    minOcc = computeValOccurences(tableNamePattern, colNamePattern, minValChar);
                } catch (Exception e) {
                    log.error("Could not compute value occurences for column:" + colNamePattern + " and value:"
                            + minValChar);
                }
                if (equidepth && !diffValFreqMap.containsKey(minVal))
                    diffValFreqMap.put(minVal, minOcc);

                try {
                    maxOcc = computeValOccurences(tableNamePattern, colNamePattern, maxValChar);
                } catch (Exception e) {
                    log.error("Could not compute value occurences for column:" + colNamePattern + " and value:"
                            + maxValChar);
                }
                if (diffValFreqMap.containsKey(maxVal))
                    diffValFreqMap.put(maxVal, maxOcc);

                diffVals = diffValFreqMap.size();
            } else {
                diffVals = computeDiffVals(tableNamePattern, colNamePattern, columnType);
            }
            if (diffVals == 0) {
                //all values are null!
                continue;
            }
            Column c = new Column(columnName, columnType, columnSize, diffVals, minVal, maxVal, diffValFreqMap);
            columnMap.put(columnName, c);
        } catch (Exception ex) {
            log.error("could not analyze column " + columnName + ":" + ex.getMessage());
        }

    }

    Table t = new Table(tblName, columnCount, toupleSize, columnMap, count, pkey);
    schema.put(tblName, t);

    // }
    // resultTables.close();
    resultColumns.close();
    return schema;

}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseTopDomainTable.java

public void createTopDomain(CFSecurityAuthorization Authorization, CFInternetTopDomainBuff Buff) {
    final String S_ProcName = "createTopDomain";
    ResultSet resultSet = null;/*w  w  w. j a  va  2  s . c  om*/
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getOptionalDescription();
        long TldId = Buff.getRequiredTldId();
        String Name = Buff.getRequiredName();
        Connection cnx = schema.getCnx();
        String sql = "exec sp_create_tdomdef ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, ClassCode);
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        if (Description != null) {
            stmtCreateByPKey.setString(argIdx++, Description);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.setLong(argIdx++, TldId);
        stmtCreateByPKey.setString(argIdx++, Name);
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFInternetTopDomainBuff createdBuff = unpackTopDomainResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredId(createdBuff.getRequiredId());
            Buff.setOptionalDescription(createdBuff.getOptionalDescription());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
            Buff.setCreatedAt(createdBuff.getCreatedAt());
            Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
            Buff.setUpdatedAt(createdBuff.getUpdatedAt());
            Buff.setRequiredTldId(createdBuff.getRequiredTldId());
            Buff.setRequiredName(createdBuff.getRequiredName());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlTagTable.java

public void createTag(CFAccAuthorization Authorization, CFAccTagBuff Buff) {
    final String S_ProcName = "createTag";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }// ww  w. j  a  va 2  s. c o m
    ResultSet resultSet = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        String Name = Buff.getRequiredName();
        String Descr = Buff.getOptionalDescr();
        Connection cnx = schema.getCnx();
        String sql = "select * from " + schema.getLowerSchemaDbName() + ".sp_create_tag( ?, ?, ?, ?, ?, ?"
                + ", " + "?" + ", " + "?" + ", " + "?" + " )";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, "CTAG");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setString(argIdx++, Name);
        if (Descr != null) {
            stmtCreateByPKey.setString(argIdx++, Descr);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFAccTagBuff createdBuff = unpackTagResultSetToBuff(resultSet);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredId(createdBuff.getRequiredId());
            Buff.setRequiredName(createdBuff.getRequiredName());
            Buff.setOptionalDescr(createdBuff.getOptionalDescr());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
            Buff.setCreatedAt(createdBuff.getCreatedAt());
            Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
            Buff.setUpdatedAt(createdBuff.getUpdatedAt());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbDb2LUW.CFGenKbDb2LUWRuleCartTable.java

public void createRuleCart(CFGenKbAuthorization Authorization, CFGenKbRuleCartBuff Buff) {
    final String S_ProcName = "createRuleCart";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from  www.j a va2 s  .co  m*/
    ResultSet resultSet = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        String Name = Buff.getRequiredName();
        String Descr = Buff.getOptionalDescr();
        String RevisionString = Buff.getOptionalRevisionString();
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_create_kbrulecart( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + " )";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, "RCT");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setString(argIdx++, Name);
        if (Descr != null) {
            stmtCreateByPKey.setString(argIdx++, Descr);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (RevisionString != null) {
            stmtCreateByPKey.setString(argIdx++, RevisionString);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFGenKbRuleCartBuff createdBuff = unpackRuleCartResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredId(createdBuff.getRequiredId());
            Buff.setRequiredName(createdBuff.getRequiredName());
            Buff.setOptionalDescr(createdBuff.getOptionalDescr());
            Buff.setOptionalRevisionString(createdBuff.getOptionalRevisionString());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseTopProjectTable.java

public void createTopProject(CFSecurityAuthorization Authorization, CFInternetTopProjectBuff Buff) {
    final String S_ProcName = "createTopProject";
    ResultSet resultSet = null;//from   w w  w  . j  a v  a2s  .  co m
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getOptionalDescription();
        long DomainId = Buff.getRequiredDomainId();
        String Name = Buff.getRequiredName();
        Connection cnx = schema.getCnx();
        String sql = "exec sp_create_tprjdef ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, ClassCode);
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        if (Description != null) {
            stmtCreateByPKey.setString(argIdx++, Description);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.setLong(argIdx++, DomainId);
        stmtCreateByPKey.setString(argIdx++, Name);
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFInternetTopProjectBuff createdBuff = unpackTopProjectResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredId(createdBuff.getRequiredId());
            Buff.setOptionalDescription(createdBuff.getOptionalDescription());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
            Buff.setCreatedAt(createdBuff.getCreatedAt());
            Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
            Buff.setUpdatedAt(createdBuff.getUpdatedAt());
            Buff.setRequiredDomainId(createdBuff.getRequiredDomainId());
            Buff.setRequiredName(createdBuff.getRequiredName());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseSubProjectTable.java

public void createSubProject(CFSecurityAuthorization Authorization, CFInternetSubProjectBuff Buff) {
    final String S_ProcName = "createSubProject";
    ResultSet resultSet = null;/*  ww w .j  ava 2s.  co  m*/
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getOptionalDescription();
        long ParentProjectId = Buff.getRequiredParentProjectId();
        String Name = Buff.getRequiredName();
        Connection cnx = schema.getCnx();
        String sql = "exec sp_create_sprjdef ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtCreateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtCreateByPKey.setString(argIdx++, ClassCode);
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        if (Description != null) {
            stmtCreateByPKey.setString(argIdx++, Description);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.setLong(argIdx++, ParentProjectId);
        stmtCreateByPKey.setString(argIdx++, Name);
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFInternetSubProjectBuff createdBuff = unpackSubProjectResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredId(createdBuff.getRequiredId());
            Buff.setOptionalDescription(createdBuff.getOptionalDescription());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
            Buff.setCreatedAt(createdBuff.getCreatedAt());
            Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
            Buff.setUpdatedAt(createdBuff.getUpdatedAt());
            Buff.setRequiredParentProjectId(createdBuff.getRequiredParentProjectId());
            Buff.setRequiredName(createdBuff.getRequiredName());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}