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:com.nabla.dc.server.ImportErrorManager.java

/**
 * Add error/*from   w  w w  .ja v  a 2  s.c  om*/
 * @param position   - row number
 * @param fieldName - field name
 * @param error - error message
 * @throws SQLException
 */
@Override
public void add(@Nullable final Integer position, @Nullable String fieldName, String error)
        throws DispatchException {
    if (isFull())
        throw new FullErrorListException();
    if (fieldName != null && fieldName.length() > MAX_FIELD_NAME)
        fieldName = fieldName.substring(0, MAX_FIELD_NAME);
    if (error == null || error.isEmpty())
        error = CommonServerErrors.INTERNAL_ERROR.toString();
    if (error.length() > MAX_ERROR_MESSAGE)
        error = error.substring(0, MAX_ERROR_MESSAGE);
    if (log.isTraceEnabled())
        log.trace("[" + position + "] " + fieldName + ":" + error);
    try {
        if (stmt == null) {
            Database.executeUpdate(conn, "DELETE FROM import_error WHERE import_data_id=?;", batchId);
            stmt = conn.prepareStatement(
                    "INSERT INTO import_error(import_data_id,line_no,field,error) VALUES(?,?,?,?);");
            stmt.setInt(COL_ID, batchId);
        }
        if (position == null)
            stmt.setNull(COL_LINE_NO, Types.INTEGER);
        else
            stmt.setInt(COL_LINE_NO, position);
        if (fieldName == null)
            stmt.setNull(COL_FIELD, Types.VARCHAR);
        else
            stmt.setString(COL_FIELD, fieldName);
        ++size;
        stmt.setString(COL_ERROR, (size < maxErrors) ? error : ServerErrors.TOO_MANY_ERRORS.toString());
        stmt.executeUpdate();
    } catch (SQLException e) {
        if (log.isErrorEnabled())
            log.error("failed to save import error to database", e);
        size = maxErrors;
        throw new FullErrorListException();
    }
}

From source file:konditer_reorganized_database.dao.GenIdDao.java

private int decrementId(String tableName) {
    String SQL_QUERY = "UPDATE cake_portal.gen_id SET ROW_COUNT = (ROW_COUNT-1) WHERE TABLE_NAME = ?";
    return jdbcTemplate.update(SQL_QUERY, new Object[] { tableName }, new int[] { Types.VARCHAR });
}

From source file:com.streamsets.pipeline.stage.it.MultiplexingIT.java

@Test
public void testMultiplexing() throws Exception {
    HiveMetadataProcessor processor = new HiveMetadataProcessorBuilder().table("${record:attribute('table')}")
            .partitions(new PartitionConfigBuilder()
                    .addPartition("country", HiveType.STRING, "${record:attribute('country')}")
                    .addPartition("year", HiveType.STRING, "${record:attribute('year')}").build())
            .build();/* www .  j  av a  2s.c o  m*/
    HiveMetastoreTarget hiveTarget = new HiveMetastoreTargetBuilder().build();

    // We build stream that have two tables
    List<Record> records = new LinkedList<>();

    Map<String, Field> map = new LinkedHashMap<>();
    map.put("id", Field.create(Field.Type.INTEGER, 1));
    map.put("name", Field.create(Field.Type.STRING, "San Francisco"));
    Record record = RecordCreator.create("s", "s:1");
    record.set(Field.create(map));
    record.getHeader().setAttribute("table", "towns");
    record.getHeader().setAttribute("country", "US");
    record.getHeader().setAttribute("year", "2016");
    records.add(record);

    map = new LinkedHashMap<>();
    map.put("id", Field.create(Field.Type.INTEGER, 1));
    map.put("customer", Field.create(Field.Type.STRING, "Santhosh"));
    map.put("value", Field.create(Field.Type.INTEGER, 200));
    record = RecordCreator.create("s", "s:1");
    record.set(Field.create(map));
    record.getHeader().setAttribute("table", "invoice");
    record.getHeader().setAttribute("country", "India");
    record.getHeader().setAttribute("year", "2015");
    records.add(record);

    map = new LinkedHashMap<>();
    map.put("id", Field.create(Field.Type.INTEGER, 2));
    map.put("name", Field.create(Field.Type.STRING, "Brno"));
    record = RecordCreator.create("s", "s:1");
    record.set(Field.create(map));
    record.getHeader().setAttribute("table", "towns");
    record.getHeader().setAttribute("country", "CR");
    record.getHeader().setAttribute("year", "2016");
    records.add(record);

    map = new LinkedHashMap<>();
    map.put("id", Field.create(Field.Type.INTEGER, 2));
    map.put("customer", Field.create(Field.Type.STRING, "Junko"));
    map.put("value", Field.create(Field.Type.INTEGER, 300));
    record = RecordCreator.create("s", "s:1");
    record.set(Field.create(map));
    record.getHeader().setAttribute("table", "invoice");
    record.getHeader().setAttribute("country", "Japan");
    record.getHeader().setAttribute("year", "2015");
    records.add(record);

    processRecords(processor, hiveTarget, records);

    assertTableExists("default.towns");
    assertTableExists("default.invoice");
    assertQueryResult("select * from towns order by id", new QueryValidator() {
        @Override
        public void validateResultSet(ResultSet rs) throws Exception {
            assertResultSetStructure(rs, new ImmutablePair("towns.id", Types.INTEGER),
                    new ImmutablePair("towns.name", Types.VARCHAR),
                    new ImmutablePair("towns.country", Types.VARCHAR),
                    new ImmutablePair("towns.year", Types.VARCHAR));

            Assert.assertTrue("Unexpected number of rows", rs.next());
            Assert.assertEquals(1, rs.getLong(1));
            Assert.assertEquals("San Francisco", rs.getString(2));
            Assert.assertEquals("US", rs.getString(3));
            Assert.assertEquals("2016", rs.getString(4));

            Assert.assertTrue("Unexpected number of rows", rs.next());
            Assert.assertEquals(2, rs.getLong(1));
            Assert.assertEquals("Brno", rs.getString(2));
            Assert.assertEquals("CR", rs.getString(3));
            Assert.assertEquals("2016", rs.getString(4));

            Assert.assertFalse("Unexpected number of rows", rs.next());
        }
    });
    assertQueryResult("select * from invoice order by id", new QueryValidator() {
        @Override
        public void validateResultSet(ResultSet rs) throws Exception {
            assertResultSetStructure(rs, new ImmutablePair("invoice.id", Types.INTEGER),
                    new ImmutablePair("invoice.customer", Types.VARCHAR),
                    new ImmutablePair("invoice.value", Types.INTEGER),
                    new ImmutablePair("invoice.country", Types.VARCHAR),
                    new ImmutablePair("invoice.year", Types.VARCHAR));

            Assert.assertTrue("Unexpected number of rows", rs.next());
            Assert.assertEquals(1, rs.getLong(1));
            Assert.assertEquals("Santhosh", rs.getString(2));
            Assert.assertEquals(200, rs.getLong(3));
            Assert.assertEquals("India", rs.getString(4));
            Assert.assertEquals("2015", rs.getString(5));

            Assert.assertTrue("Unexpected number of rows", rs.next());
            Assert.assertEquals(2, rs.getLong(1));
            Assert.assertEquals("Junko", rs.getString(2));
            Assert.assertEquals(300, rs.getLong(3));
            Assert.assertEquals("Japan", rs.getString(4));
            Assert.assertEquals("2015", rs.getString(5));

            Assert.assertFalse("Unexpected number of rows", rs.next());
        }
    });
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWVersionTable.java

public void createVersion(CFCrmAuthorization Authorization, CFCrmVersionBuff Buff) {
    final String S_ProcName = "createVersion";
    ResultSet resultSet = null;//from w  w w . jav a  2  s.c  o  m
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getOptionalDescription();
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_create_verndef( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )";
        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);
        }
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFCrmVersionBuff createdBuff = unpackVersionResultSetToBuff(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());
        } 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.Stat.java

private int computeColumnSize(String columnName, int columnType, String table_sample) throws Exception {
    int columnSize = 0;
    if (columnType == Types.INTEGER || columnType == Types.REAL || columnType == Types.DOUBLE
            || columnType == Types.DECIMAL || columnType == Types.FLOAT || columnType == Types.NUMERIC) {
        columnSize = NUM_SIZE;//from   w w w .  j a  v  a2  s  .co m
    } else if (columnType == Types.VARCHAR) {
        String query0 = "select max(length(`" + columnName + "`)) as length from (select `" + columnName
                + "` from `" + table_sample + "`)" + " where `" + columnName + "` is not null limit "
                + MAX_STRING_SAMPLE;

        Statement stmt0 = con.createStatement();
        ResultSet rs0 = stmt0.executeQuery(query0);

        while (rs0.next()) {
            columnSize = rs0.getInt("length");
        }
        rs0.close();
        stmt0.close();

    } else if (columnType == Types.BLOB)
        columnSize = BLOB_SIZE;

    return columnSize;
}

From source file:org.hxzon.util.db.springjdbc.StatementCreatorUtils.java

/**
 * Derive a default SQL type from the given Java type.
 * @param javaType the Java type to translate
 * @return the corresponding SQL type, or {@code null} if none found
 *///from   w w  w. j  a v  a  2s . c  o  m
public static int javaTypeToSqlParameterType(Class<?> javaType) {
    Integer sqlType = javaTypeToSqlTypeMap.get(javaType);
    if (sqlType != null) {
        return sqlType;
    }
    if (Number.class.isAssignableFrom(javaType)) {
        return Types.NUMERIC;
    }
    if (isStringValue(javaType)) {
        return Types.VARCHAR;
    }
    if (isDateValue(javaType) || Calendar.class.isAssignableFrom(javaType)) {
        return Types.TIMESTAMP;
    }
    return SqlTypeValue.TYPE_UNKNOWN;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlSecDeviceTable.java

public void createSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) {
    final String S_ProcName = "createSecDevice";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from  w w  w.j  a  v  a  2 s  .c o m*/
    ResultSet resultSet = null;
    try {
        UUID SecUserId = Buff.getRequiredSecUserId();
        String DevName = Buff.getRequiredDevName();
        String PubKey = Buff.getOptionalPubKey();
        Connection cnx = schema.getCnx();
        String sql = "select * from " + schema.getLowerDbSchemaName() + ".sp_create_secdev( ?, ?, ?, ?, ?, ?"
                + ", " + "?" + ", " + "?" + ", " + "cast( ? as text )" + " )";
        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++, "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);
        }
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFSecuritySecDeviceBuff createdBuff = unpackSecDeviceResultSetToBuff(resultSet);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
            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().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWDomainTable.java

public void createDomain(CFCrmAuthorization Authorization, CFCrmDomainBuff Buff) {
    final String S_ProcName = "createDomain";
    ResultSet resultSet = null;/*w  ww  .  j a va  2  s .c  om*/
    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();
        final String sql = "CALL 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()) {
            CFCrmDomainBuff 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:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWTopDomainTable.java

public void createTopDomain(CFCrmAuthorization Authorization, CFCrmTopDomainBuff Buff) {
    final String S_ProcName = "createTopDomain";
    ResultSet resultSet = null;/*from  www  .  ja va2  s  . co  m*/
    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();
        final String sql = "CALL 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()) {
            CFCrmTopDomainBuff 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.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWRealProjectTable.java

public void createRealProject(CFCrmAuthorization Authorization, CFCrmRealProjectBuff Buff) {
    final String S_ProcName = "createRealProject";
    ResultSet resultSet = null;//from w w w. j a  v a2 s  .  c  o m
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getOptionalDescription();
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_create_rprjdef( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )";
        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);
        }
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFCrmRealProjectBuff createdBuff = unpackRealProjectResultSetToBuff(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());
        } 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;
        }
    }
}