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:org.marccarre.spring.db.testing.FooStoredProcedure.java

public FooStoredProcedure(DataSource dataSource) {
    super(dataSource, "GetFoosById");
    declareParameter(new SqlParameter(FOO_ID, Types.INTEGER));
    declareParameter(new SqlReturnResultSet(RESULTS, new FooRowMapper()));
    compile();//from w  ww  . j av  a 2 s . c o  m
}

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

@Parameterized.Parameters(name = "type({0})")
public static Collection<Object[]> data() throws Exception {
    return Arrays.asList(new Object[][] {
            // Supported types
            { Field.create(Field.Type.INTEGER, 1), partition(HiveType.INT), true, Types.INTEGER, 1 },
            { Field.create(Field.Type.LONG, 1), partition(HiveType.BIGINT), true, Types.BIGINT, 1L },
            { Field.create(Field.Type.STRING, "value"), partition(HiveType.STRING), true, Types.VARCHAR,
                    "value" },
            // Unsupported types
            { Field.create(Field.Type.BOOLEAN, true), partition(HiveType.BOOLEAN), false, 0, null },
            { Field.create(Field.Type.DATE, new Date()), partition(HiveType.DATE), false, 0, null },
            { Field.create(Field.Type.FLOAT, 1.2), partition(HiveType.FLOAT), false, 0, null },
            { Field.create(Field.Type.DOUBLE, 1.2), partition(HiveType.DOUBLE), false, 0, null },
            { Field.create(Field.Type.BYTE_ARRAY, new byte[] { 0x00 }), partition(HiveType.BINARY), false, 0,
                    null },/*from ww  w  .j  a va 2 s  .c  o  m*/
            // Decimal fails with java.lang.ArrayIndexOutOfBoundsException
            //      {Field.create(Field.Type.DECIMAL, BigDecimal.valueOf(1.5)), partition(HiveType.DECIMAL), false, 0, null},
    });
}

From source file:demo.repository.DemoProcedure.java

/**
 * Executes {@code GREPO_DEMO.DEMO_FUNCTION}.
 *
 * @param param1 The p_string param.//from   www. j a  va2  s . c  o  m
 * @param param2 The p_integer param.
 * @return Returns the p_result.
 */
@GenericProcedure(sql = "grepo_demo.demo_function", returnParamName = "p_result", function = true)
@Out(name = "p_result", sqlType = Types.VARCHAR)
String executeDemoFunction(@In(name = "p_string", sqlType = Types.VARCHAR) String param1,
        @In(name = "p_integer", sqlType = Types.INTEGER) int param2);

From source file:konditer_reorganized_database.dao.OrdereDao.java

@Override
public void addOrdere(int orderId, int customerId, int orderStatusId, int deliveryId, Date orderDateIncome,
        Date orderDateEnd, double orderCakePrice, double orderDeliveryPrice, String orderInsidesId,
        String orderInfo) {//from  w ww  .  ja va2 s.co  m
    String SQL_QUERY = "INSERT INTO orders ( ORDER_ID, " + "CUSTOMER_ID, " + "ORDER_STATUS_ID, "
            + "DELIVERY_ID, " + "ORDER_DATE_INCOME, " + "ORDER_DATE_END, " + "ORDER_CAKE_PRICE, "
            + "ORDER_DELIVERY_PRICE, " + "ORDER_INSIDES_ID, " + "ORDER_INFO ) "
            + "VALUES (?,?,?,?,?,?,?,?,?,?)";

    int rowCount = jdbcTemplate.update(SQL_QUERY,
            new Object[] { orderId, customerId, orderStatusId, deliveryId, orderDateIncome, orderDateEnd,
                    orderCakePrice, orderDeliveryPrice, orderInsidesId, orderInfo },
            new int[] { Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP,
                    Types.TIMESTAMP, Types.DOUBLE, Types.DOUBLE, Types.VARCHAR, Types.VARCHAR });
    Logger.getLogger(CakeDao.class.getName()).log(Level.SEVERE, " : {0} .",
            rowCount);
    System.out.println(ordereDao.getOrdere(orderId).toString());
}

From source file:net.chrisrichardson.bankingExample.domain.jdbc.JdbcAccountDao.java

public void addAccount(Account account) {
    logger.debug("adding account");
    int count = jdbcTemplate.update(
            "INSERT INTO BANK_ACCOUNT(accountId, BALANCE, overdraftPolicy, dateOpened, requiredYearsOpen, limit) values(?, ?, ?, ?, ?, ?)",
            new Object[] { account.getAccountId(), account.getBalance(), account.getOverdraftPolicy(),
                    new Timestamp(account.getDateOpened().getTime()), account.getRequiredYearsOpen(),
                    account.getLimit() },
            new int[] { Types.VARCHAR, Types.DOUBLE, Types.INTEGER, Types.TIMESTAMP, Types.DOUBLE,
                    Types.DOUBLE });
    Assert.isTrue(count == 1);//from   w w w .  j  a  v a 2s  . com
}

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

@Parameterized.Parameters(name = "type({0})")
public static Collection<Object[]> data() throws Exception {
    return Arrays.asList(new Object[][] { { Field.create(Field.Type.BOOLEAN, true), true, Types.BOOLEAN, true },
            { Field.create(Field.Type.CHAR, 'A'), true, Types.VARCHAR, "A" },
            { Field.create(Field.Type.BYTE, (byte) 0x00), false, 0, null },
            { Field.create(Field.Type.SHORT, 10), true, Types.INTEGER, 10 },
            { Field.create(Field.Type.INTEGER, 10), true, Types.INTEGER, 10 },
            { Field.create(Field.Type.LONG, 10), true, Types.BIGINT, 10L },
            { Field.create(Field.Type.FLOAT, 1.5), true, Types.FLOAT, 1.5 },
            { Field.create(Field.Type.DOUBLE, 1.5), true, Types.DOUBLE, 1.5 },
            { Field.create(Field.Type.DATE, new Date(116, 5, 13)), true, Types.DATE, new Date(116, 5, 13) },
            { Field.create(Field.Type.DATETIME, date), true, Types.VARCHAR, datetimeFormat.format(date) },
            { Field.create(Field.Type.TIME, date), true, Types.VARCHAR, timeFormat.format(date) },
            { Field.create(Field.Type.DECIMAL, BigDecimal.valueOf(1.5)), true, Types.DECIMAL,
                    new BigDecimal(BigInteger.valueOf(15), 1, new MathContext(2, RoundingMode.FLOOR)) },
            { Field.create(Field.Type.STRING, "StreamSets"), true, Types.VARCHAR, "StreamSets" },
            { Field.create(Field.Type.BYTE_ARRAY, new byte[] { (byte) 0x00 }), true, Types.BINARY,
                    new byte[] { (byte) 0x00 } },
            { Field.create(Field.Type.MAP, Collections.emptyMap()), false, 0, null },
            { Field.create(Field.Type.LIST, Collections.emptyList()), false, 0, null },
            { Field.create(Field.Type.LIST_MAP, new LinkedHashMap<>()), false, 0, null }, });
}

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

@Override
public void addCustomer(int customerId, int discountId, String customerLastName, String customerFirstName,
        String customerParentName, Date customerDateBorn, String customerInfo) {
    String SQL_QUERY = "INSERT INTO customers ( CUSTOMER_ID, " + "DISCOUNT_ID, " + "CUSTOMER_LAST_NAME, "
            + "CUSTOMER_FIRST_NAME, " + "CUSTOMER_PARENT_NAME, " + "CUSTOMER_DATE_BORN, " + "CUSTOMER_INFO ) "
            + "VALUES (?,?,?,?,?,?,?)";
    int rowCount = 0;
    try {//from   www.  j a  va  2s. co m
        rowCount = jdbcTemplate.update(SQL_QUERY,
                new Object[] { customerId, discountId, customerLastName, customerFirstName, customerParentName,
                        customerDateBorn, customerInfo },
                new int[] { Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.TIMESTAMP, Types.VARCHAR });
        Logger.getLogger(CustomerDao.class.getName()).log(Level.SEVERE,
                " : {0} .", rowCount);
        System.out.println(customerDao.getCustomer(customerId).toString());
    } catch (DataAccessException e) {
        rowCount = 0;
        Logger.getLogger(CustomerDao.class.getName()).log(Level.SEVERE,
                "    .  ?: {0} .",
                rowCount);
    }
}

From source file:edumsg.core.commands.tweet.UnFavoriteCommand.java

@Override
public void execute() {
    try {/*from   www.  ja v a 2 s.c  o  m*/
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(true);
        proc = dbConn.prepareCall("{? = call unfavorite(?,?)}");
        proc.setPoolable(true);
        proc.registerOutParameter(1, Types.INTEGER);
        proc.setInt(2, Integer.parseInt(map.get("tweet_id")));
        proc.setString(3, map.get("session_id"));
        proc.execute();

        int favorites = proc.getInt(1);

        root.put("app", map.get("app"));
        root.put("method", map.get("method"));
        root.put("status", "ok");
        root.put("code", "200");
        root.put("favorites", favorites);
        try {
            CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"),
                    LOGGER);
            String cacheEntry = UserCache.userCache.get("user_tweets:" + map.get("session_id"));
            if (cacheEntry != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                UserCache.userCache.set("user_tweets:" + map.get("session_id"), cacheEntryJson.toString());
            }
            String cacheEntry1 = UserCache.userCache.get("timeline:" + map.get("session_id"));
            if (cacheEntry1 != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry1);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                UserCache.userCache.set("timeline:" + map.get("session_id"), cacheEntryJson.toString());
            }
            String cacheEntry2 = TweetsCache.tweetCache.get("get_earliest_replies:" + map.get("session_id"));
            if (cacheEntry2 != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry2);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                TweetsCache.tweetCache.set("get_earliest_replies:" + map.get("session_id"),
                        cacheEntryJson.toString());
            }
            String cacheEntry3 = TweetsCache.tweetCache.get("get_replies:" + map.get("session_id"));
            if (cacheEntry3 != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry3);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                TweetsCache.tweetCache.set("get_replies:" + map.get("session_id"), cacheEntryJson.toString());
            }
            String cacheEntry4 = ListCache.listCache.get("get_list_feeds:" + map.get("session_id"));
            if (cacheEntry4 != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry4);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                ListCache.listCache.set("get_list_feeds:" + map.get("session_id"), cacheEntryJson.toString());
            }
        } catch (JsonGenerationException e) {
            //LOGGER.log(Level.OFF, e.getMessage(), e);
        } catch (JsonMappingException e) {
            //LOGGER.log(Level.OFF, e.getMessage(), e);
        } catch (IOException e) {
            //LOGGER.log(Level.OFF, e.getMessage(), e);
        }
        //            catch (JSONException e) {
        //                e.printStackTrace();
        //            }

    } catch (PSQLException e) {
        CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"),
                LOGGER);
        //LOGGER.log(Level.OFF, e.getMessage(), e);
    } catch (SQLException e) {
        CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"),
                LOGGER);
        //LOGGER.log(Level.OFF, e.getMessage(), e);
    } finally {
        PostgresConnection.disconnect(null, proc, dbConn);
    }
}

From source file:edumsg.core.commands.tweet.FavoriteCommand.java

@Override
public void execute() {
    try {// w ww  .j a v  a2 s. c  om
        dbConn = PostgresConnection.getDataSource().getConnection();
        dbConn.setAutoCommit(true);
        proc = dbConn.prepareCall("{? = call favorite(?,?)}");
        proc.setPoolable(true);
        proc.registerOutParameter(1, Types.INTEGER);
        proc.setInt(2, Integer.parseInt(map.get("tweet_id")));
        proc.setString(3, map.get("session_id"));
        proc.execute();

        int favorites = proc.getInt(1);

        root.put("app", map.get("app"));
        root.put("method", map.get("method"));
        root.put("status", "ok");
        root.put("code", "200");
        root.put("favorites", favorites);
        try {
            CommandsHelp.submit(map.get("app"), mapper.writeValueAsString(root), map.get("correlation_id"),
                    LOGGER);
            String cacheEntry = UserCache.userCache.get("user_tweets:" + map.get("session_id"));
            if (cacheEntry != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                UserCache.userCache.set("user_tweets:" + map.get("session_id"), cacheEntryJson.toString());
            }
            String cacheEntry1 = UserCache.userCache.get("timeline:" + map.get("session_id"));
            if (cacheEntry1 != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry1);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                UserCache.userCache.set("timeline:" + map.get("session_id"), cacheEntryJson.toString());
            }
            String cacheEntry2 = TweetsCache.tweetCache.get("get_earliest_replies:" + map.get("session_id"));
            if (cacheEntry2 != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry2);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                TweetsCache.tweetCache.set("get_earliest_replies:" + map.get("session_id"),
                        cacheEntryJson.toString());
            }
            String cacheEntry3 = TweetsCache.tweetCache.get("get_replies:" + map.get("session_id"));
            if (cacheEntry3 != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry3);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                TweetsCache.tweetCache.set("get_replies:" + map.get("session_id"), cacheEntryJson.toString());
            }
            String cacheEntry4 = ListCache.listCache.get("get_list_feeds:" + map.get("session_id"));
            if (cacheEntry4 != null) {
                JSONObject cacheEntryJson = new JSONObject(cacheEntry4);
                cacheEntryJson.put("cacheStatus", "invalid");
                //                    System.out.println("invalidated");
                ListCache.listCache.set("get_list_feeds:" + map.get("session_id"), cacheEntryJson.toString());
            }
        } catch (JsonGenerationException e) {
            //LOGGER.log(Level.OFF, e.getMessage(), e);
        } catch (JsonMappingException e) {
            //LOGGER.log(Level.OFF, e.getMessage(), e);
        } catch (IOException e) {
            //LOGGER.log(Level.OFF, e.getMessage(), e);
        }
        //            catch (JSONException e) {
        //                // TODO Auto-generated catch block
        //                e.printStackTrace();
        //            }

    } catch (PSQLException e) {
        if (e.getMessage().contains("unique constraint")) {
            CommandsHelp.handleError(map.get("app"), map.get("method"), "You already favorited this tweet",
                    map.get("correlation_id"), LOGGER);
        } else {
            CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(),
                    map.get("correlation_id"), LOGGER);
        }

        //LOGGER.log(Level.OFF, e.getMessage(), e);
    } catch (SQLException e) {
        CommandsHelp.handleError(map.get("app"), map.get("method"), e.getMessage(), map.get("correlation_id"),
                LOGGER);
        //LOGGER.log(Level.OFF, e.getMessage(), e);
    } finally {
        PostgresConnection.disconnect(null, proc, dbConn, null);
    }
}

From source file:com.seguriboxltv.core.dao.impl.HsmKeyDaoImpl.java

@Override
public void Create(Hsmkey myHsmKey, String userName, String hostName) throws Exception {

    sql = "{call HsmKeyCreate(?,?,?,?,?,?,?,?,?)}";
    try {//www.j a  va  2s .com
        conn = dataSource.getConnection();
        cstmt = conn.prepareCall(sql);
        cstmt.setInt("AlgorithmSignId", myHsmKey.getAlgorithmSignId());
        cstmt.setString("KeyTag", myHsmKey.getKeyTag());
        cstmt.setInt("KeySize", myHsmKey.getKeySize());
        cstmt.setString("Oid", myHsmKey.getOid());
        cstmt.setBytes("Certificate", myHsmKey.getCertificate());
        cstmt.setDate("CertificateExpiration", myHsmKey.getCertificateExpiration());//Modificar
        cstmt.setString("UserName", userName);
        cstmt.setString("HostName", hostName);
        cstmt.registerOutParameter("HsmKeyId", Types.INTEGER);
        boolean results = cstmt.execute();
        do {
            if (results) {
                rsl = cstmt.getResultSet();
                if (rsl.next()) {
                    returnCode = rsl.getInt("ReturnCode");
                    returnMessage = rsl.getString("ReturnMessage");
                }
                if (returnCode > 0) {
                    throw new Exception(returnMessage);
                }
            }
        } while (results);
    } catch (SQLException e) {
        throw e;
    } catch (Exception e1) {
        throw e1;
    }
}