Example usage for java.sql Types INTEGER

List of usage examples for java.sql Types INTEGER

Introduction

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

Prototype

int INTEGER

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

Click Source Link

Document

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

Usage

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelModifierTable.java

public void createGelModifier(CFGenKbAuthorization Authorization, CFGenKbGelModifierBuff Buff) {
    final String S_ProcName = "createGelModifier";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from   w ww.  j av a  2 s  .  c  o  m*/
    ResultSet resultSet = null;
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        long CartridgeId = Buff.getRequiredCartridgeId();
        Integer CallerId = Buff.getOptionalCallerId();
        Integer PrevId = Buff.getOptionalPrevId();
        Integer NextId = Buff.getOptionalNextId();
        String SourceText = Buff.getRequiredSourceText();
        Integer FirstInstId = Buff.getOptionalFirstInstId();
        Integer LastInstId = Buff.getOptionalLastInstId();
        Integer RemainderInstId = Buff.getOptionalRemainderInstId();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_create_gelmodifier( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + " )";
        if (stmtCreateByPKey == null) {
            stmtCreateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        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);
        stmtCreateByPKey.setLong(argIdx++, CartridgeId);
        if (CallerId != null) {
            stmtCreateByPKey.setInt(argIdx++, CallerId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (PrevId != null) {
            stmtCreateByPKey.setInt(argIdx++, PrevId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (NextId != null) {
            stmtCreateByPKey.setInt(argIdx++, NextId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtCreateByPKey.setString(argIdx++, SourceText);
        if (FirstInstId != null) {
            stmtCreateByPKey.setInt(argIdx++, FirstInstId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (LastInstId != null) {
            stmtCreateByPKey.setInt(argIdx++, LastInstId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        if (RemainderInstId != null) {
            stmtCreateByPKey.setInt(argIdx++, RemainderInstId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        try {
            resultSet = stmtCreateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFGenKbGelModifierBuff createdBuff = unpackGelModifierResultSetToBuff(resultSet);
            if ((resultSet != null) && 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.setRequiredCartridgeId(createdBuff.getRequiredCartridgeId());
            Buff.setRequiredGelInstId(createdBuff.getRequiredGelInstId());
            Buff.setOptionalCallerId(createdBuff.getOptionalCallerId());
            Buff.setOptionalPrevId(createdBuff.getOptionalPrevId());
            Buff.setOptionalNextId(createdBuff.getOptionalNextId());
            Buff.setRequiredSourceText(createdBuff.getRequiredSourceText());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setOptionalFirstInstId(createdBuff.getOptionalFirstInstId());
            Buff.setOptionalLastInstId(createdBuff.getOptionalLastInstId());
            Buff.setOptionalRemainderInstId(createdBuff.getOptionalRemainderInstId());
        } 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:org.apache.kylin.jdbc.KylinConnectionTest.java

private IRemoteClient.QueryResult getMockResult() {
    ArrayList<ColumnMetaData> columnMeta = new ArrayList<>();
    columnMeta.add(new ColumnMetaData(0, false, true, false, false, 1, true, 1, "VAL", "VAL", null, 10, 0, null,
            null, ColumnMetaData.scalar(Types.INTEGER, "INTEGER", ColumnMetaData.Rep.INTEGER), true, false,
            false, "java.lang.Integer"));
    ArrayList<Object> list = new ArrayList<>();
    list.add(new Object[] { 1 });
    return new IRemoteClient.QueryResult(columnMeta, list);
}

From source file:it.alidays.mapengine.codegenerator.MapperEngineCodeGenerator.java

private static void createMapClass(Retrieve retrieve, Map<String, Integer> columns, String packageName,
        File destinationDir)/*from w  w  w. ja va 2  s.  c om*/
        throws JClassAlreadyExistsException, MapperEngineCodeGeneratorException, IOException {
    JCodeModel codeModel = new JCodeModel();
    JDefinedClass mapClass = codeModel._class(String.format("%s.%sMap", packageName, retrieve.getId()));
    mapClass.javadoc().append("Auto generated class. Do not modify!");

    // Constructor
    JMethod constructor = mapClass.constructor(JMod.PROTECTED);
    constructor.param(codeModel.ref(Map.class).narrow(String.class, Object.class), "data");

    for (String column : columns.keySet()) {
        String varName = WordUtils.uncapitalize(column);
        Class<?> type = null;
        switch (columns.get(column)) {
        case Types.INTEGER:
            type = Integer.class;
            break;
        case Types.VARCHAR:
            type = String.class;
            break;
        case Types.DECIMAL:
            type = BigDecimal.class;
            break;
        default:
            throw new MapperEngineCodeGeneratorException(
                    String.format("Missing Type map for column %s: %d", column, columns.get(column)));
        }

        JFieldVar field = mapClass.field(JMod.PRIVATE | JMod.FINAL, type, varName);

        // Getter
        JMethod getter = mapClass.method(JMod.PUBLIC, type, String.format("get%s", column));
        getter.body()._return(JExpr._this().ref(field));

        constructor.body().assign(JExpr._this().ref(varName),
                JExpr.cast(codeModel.ref(type), JExpr.ref("data").invoke("get").arg(column)));
    }
    codeModel.build(destinationDir);
}

From source file:konditer.client.dao.CustomerDao.java

@Override
public int updateCustomer(int customerId, int newDiscountId, String newCustomerLastName,
        String newCustomerFirstName, String newCustomerParentName, Date newCustomerDateBorn,
        String newCustomerInfo) {
    System.out.println("  CustomerDao.updateCustomer c : newCustomerDateBorn="
            + newCustomerDateBorn);/*  w ww  . jav a 2s.c om*/
    String SQL_QUERY = "UPDATE customers " + "SET DISCOUNT_ID = ?, " + "CUSTOMER_LAST_NAME = ?, "
            + "CUSTOMER_FIRST_NAME = ?, " + "CUSTOMER_PARENT_NAME = ?, " + "CUSTOMER_DATE_BORN = ?, "
            + "CUSTOMER_INFO = ? " + "WHERE CUSTOMER_ID = ?";
    int rowCount = 0;
    try {
        rowCount = jdbcTemplate.update(SQL_QUERY,
                new Object[] { newDiscountId, newCustomerLastName, newCustomerFirstName, newCustomerParentName,
                        newCustomerDateBorn, newCustomerInfo, customerId },
                new int[] { Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP,
                        Types.VARCHAR, Types.INTEGER });
        Logger.getLogger(CustomerDao.class.getName()).log(Level.SEVERE,
                "   .  ?: {0} .",
                rowCount + "\n" + customerDao.getCustomer(customerId).toString());
    } catch (DataAccessException e) {
        rowCount = 0;
        Logger.getLogger(CustomerDao.class.getName()).log(Level.SEVERE,
                "     .  ?: {0} .",
                rowCount);
    }
    return rowCount;
}

From source file:com.act.lcms.db.model.StandardIonResult.java

protected void bindInsertOrUpdateParameters(PreparedStatement stmt, String chemical, Integer standardWellId,
        List<Integer> negativeWellIds, LinkedHashMap<String, XZ> analysisResults,
        Map<String, String> plottingResultFileMapping, String bestMetlinIon, Integer manualOverrideId)
        throws SQLException, IOException {
    stmt.setString(DB_FIELD.CHEMICAL.getInsertUpdateOffset(), chemical);
    stmt.setInt(DB_FIELD.STANDARD_WELL_ID.getInsertUpdateOffset(), standardWellId);
    stmt.setString(DB_FIELD.NEGATIVE_WELL_IDS.getInsertUpdateOffset(),
            OBJECT_MAPPER.writeValueAsString(negativeWellIds));
    stmt.setString(DB_FIELD.PLOTTING_RESULT_PATHS.getInsertUpdateOffset(),
            serializePlottingPaths(plottingResultFileMapping));
    stmt.setString(DB_FIELD.STANDARD_ION_RESULTS.getInsertUpdateOffset(),
            serializeStandardIonAnalysisResult(analysisResults));
    stmt.setString(DB_FIELD.BEST_METLIN_ION.getInsertUpdateOffset(), bestMetlinIon);

    if (manualOverrideId == null) {
        stmt.setNull(DB_FIELD.MANUAL_OVERRIDE.getInsertUpdateOffset(), Types.INTEGER);
    } else {//from   w  ww.  j  av  a2 s. c om
        stmt.setInt(DB_FIELD.MANUAL_OVERRIDE.getInsertUpdateOffset(), manualOverrideId);
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java

public int nextSecGroupIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) {
    final String S_ProcName = "nextSecGroupIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }//ww w.j a  v  a  2 s  .  c o m
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextSecGroupIdGen = null;
    try {
        String sql = "{ call sp_next_secgroupidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextSecGroupIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextSecGroupIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER);
        stmtSelectNextSecGroupIdGen.setLong(argIdx++, Id);
        stmtSelectNextSecGroupIdGen.execute();
        int nextId = stmtSelectNextSecGroupIdGen.getInt(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextSecGroupIdGen != null) {
            try {
                stmtSelectNextSecGroupIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextSecGroupIdGen = null;
        }
    }
}

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

@Test
public void zeroScale() throws Exception {
    executeUpdate("CREATE TABLE `tbl` (id int, dec decimal(2, 0)) PARTITIONED BY (dt string) STORED AS AVRO");

    HiveMetadataProcessor processor = new HiveMetadataProcessorBuilder().decimalConfig(2, 0).build();
    HiveMetastoreTarget hiveTarget = new HiveMetastoreTargetBuilder().build();

    List<Record> records = new LinkedList<>();

    Map<String, Field> map = new LinkedHashMap<>();
    map.put("id", Field.create(Field.Type.INTEGER, 1));
    map.put("dec", Field.create(BigDecimal.valueOf(12)));
    Record record = RecordCreator.create("s", "s:1");
    record.set(Field.create(map));
    records.add(record);/* w  ww.j a  va2 s  . co m*/

    processRecords(processor, hiveTarget, records);

    assertQueryResult("select * from tbl order by id", new QueryValidator() {
        @Override
        public void validateResultSet(ResultSet rs) throws Exception {
            assertResultSetStructure(rs, new ImmutablePair("tbl.id", Types.INTEGER),
                    new ImmutablePair("tbl.dec", Types.DECIMAL), new ImmutablePair("tbl.dt", Types.VARCHAR));

            Assert.assertTrue("Table tbl doesn't contain any rows", rs.next());
            Assert.assertEquals(1, rs.getLong(1));
            Assert.assertEquals(BigDecimal.valueOf(12), rs.getBigDecimal(2));

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

From source file:konditer.client.dao.OrdereDao.java

@Override
public int updateOrdere(int orderId, int newCustomerId, int newDeliveryId, int newOrderStatusId,
        Date newOrderDateIncome, Date newOrderDateEnd, double orderCakePrice, double newOrderDeliveryPrice,
        double newOrderWeight, String orderInsidesId, String newOrderInfo) {
    String SQL_QUERY = "UPDATE orders " + "SET CUSTOMER_ID = ?, " + "DELIVERY_ID = ?, "
            + "ORDER_STATUS_ID = ?, " + "ORDER_DATE_INCOME = ?, " + "ORDER_DATE_END = ?, " + "ORDER_INFO = ?, "
            + "ORDER_CAKE_PRICE = ?, " + "ORDER_DELIVERY_PRICE = ?, " + "ORDER_WEIGHT = ?, "
            + "ORDER_INSIDES_ID = ? " + "WHERE ORDER_ID = ? ";
    int rowCount = 0;
    rowCount = jdbcTemplate.update(SQL_QUERY,
            new Object[] { newCustomerId, newDeliveryId, newOrderStatusId, newOrderDateIncome, newOrderDateEnd,
                    newOrderInfo, orderCakePrice, newOrderDeliveryPrice, newOrderWeight, orderInsidesId,
                    orderId },/*  w w  w.  j  a  v  a 2s  . c  om*/
            new int[] { Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP,
                    Types.VARCHAR, Types.DOUBLE, Types.DOUBLE, Types.DOUBLE, Types.VARCHAR, Types.INTEGER });
    Logger.getLogger(OrdereDao.class.getName()).log(Level.SEVERE,
            " : {0} .", rowCount);
    return rowCount;
}

From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbPgSql.CFGenKbPgSqlNmTokenFormatterTable.java

public void createNmTokenFormatter(CFGenKbAuthorization Authorization, CFGenKbNmTokenFormatterBuff Buff) {
    final String S_ProcName = "createNmTokenFormatter";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from  ww  w  . j a v  a  2 s  .  c om
    ResultSet resultSet = null;
    try {
        String ClassCode = Buff.getClassCode();
        long TenantId = Buff.getRequiredTenantId();
        long CartridgeId = Buff.getRequiredCartridgeId();
        short RuleTypeId = Buff.getRequiredRuleTypeId();
        String Name = Buff.getRequiredName();
        short ToolSetId = Buff.getRequiredToolSetId();
        Short ScopeDefId = Buff.getOptionalScopeDefId();
        short GenDefId = Buff.getRequiredGenDefId();
        Integer GelExecutableId = Buff.getOptionalGelExecutableId();
        Connection cnx = schema.getCnx();
        String sql = "select * from " + schema.getLowerSchemaDbName()
                + ".sp_create_kbnmtokenfmt( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )";
        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);
        stmtCreateByPKey.setLong(argIdx++, CartridgeId);
        stmtCreateByPKey.setShort(argIdx++, RuleTypeId);
        stmtCreateByPKey.setString(argIdx++, Name);
        stmtCreateByPKey.setShort(argIdx++, ToolSetId);
        if (ScopeDefId != null) {
            stmtCreateByPKey.setShort(argIdx++, ScopeDefId.shortValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtCreateByPKey.setShort(argIdx++, GenDefId);
        if (GelExecutableId != null) {
            stmtCreateByPKey.setInt(argIdx++, GelExecutableId.intValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        resultSet = stmtCreateByPKey.executeQuery();
        if (resultSet.next()) {
            CFGenKbNmTokenFormatterBuff createdBuff = unpackNmTokenFormatterResultSetToBuff(resultSet);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
            Buff.setRequiredTenantId(createdBuff.getRequiredTenantId());
            Buff.setRequiredCartridgeId(createdBuff.getRequiredCartridgeId());
            Buff.setRequiredItemId(createdBuff.getRequiredItemId());
            Buff.setRequiredRuleTypeId(createdBuff.getRequiredRuleTypeId());
            Buff.setRequiredName(createdBuff.getRequiredName());
            Buff.setRequiredToolSetId(createdBuff.getRequiredToolSetId());
            Buff.setOptionalScopeDefId(createdBuff.getOptionalScopeDefId());
            Buff.setRequiredGenDefId(createdBuff.getRequiredGenDefId());
            Buff.setOptionalGelExecutableId(createdBuff.getOptionalGelExecutableId());
            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:com.streamsets.pipeline.stage.it.DriftIT.java

@Test
public void testNewColumnInTheMiddle() throws Exception {
    HiveMetadataProcessor processor = new HiveMetadataProcessorBuilder().table("multiple").build();
    HiveMetastoreTarget hiveTarget = new HiveMetastoreTargetBuilder().build();

    List<Record> records = new LinkedList<>();

    Map<String, Field> map = new LinkedHashMap<>();
    map.put("id", Field.create(Field.Type.INTEGER, 1));
    map.put("value", Field.create(Field.Type.STRING, "exists"));
    Record record = RecordCreator.create("s", "s:1");
    record.set(Field.create(map));
    records.add(record);/*from   w  w  w.  jav  a2 s.  c  o  m*/

    map = new LinkedHashMap<>();
    map.put("id", Field.create(Field.Type.INTEGER, 2));
    map.put("new_column", Field.create(Field.Type.STRING, "new value"));
    map.put("value", Field.create(Field.Type.STRING, "exists"));
    record = RecordCreator.create("s", "s:1");
    record.set(Field.create(map));
    records.add(record);

    processRecords(processor, hiveTarget, records);

    assertQueryResult("select * from multiple order by id", new QueryValidator() {
        @Override
        public void validateResultSet(ResultSet rs) throws Exception {
            assertResultSetStructure(rs, new ImmutablePair("multiple.id", Types.INTEGER),
                    new ImmutablePair("multiple.value", Types.VARCHAR),
                    new ImmutablePair("multiple.new_column", Types.VARCHAR),
                    new ImmutablePair("multiple.dt", Types.VARCHAR));

            Assert.assertTrue("Table tbl doesn't contain any rows", rs.next());
            Assert.assertEquals(1, rs.getLong(1));
            Assert.assertEquals("exists", rs.getString(2));
            Assert.assertEquals(null, rs.getString(3));

            Assert.assertTrue("Unexpected number of rows", rs.next());
            Assert.assertEquals(2, rs.getLong(1));
            Assert.assertEquals("exists", rs.getString(2));
            Assert.assertEquals("new value", rs.getString(3));

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