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.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseTenantTable.java

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

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

From source file:com.fns.grivet.repo.JdbcEntityRepository.java

@Override
public List<EntityAttributeValue> findByCreatedTime(Integer cid, LocalDateTime createdTimeStart,
        LocalDateTime createdTimeEnd) {
    String sql = QueryBuilder.newInstance().appendCreatedTimeRange().build();
    log.trace(String.format("JdbcEntityRepository.findByCreatedTime[sql=%s]", sql));
    return mapRows(jdbcTemplate.query(sql, new SqlRowSetResultSetExtractor(),
            new SqlParameterValue(Types.INTEGER, cid),
            new SqlParameterValue(Types.TIMESTAMP, Timestamp.valueOf(createdTimeStart)),
            new SqlParameterValue(Types.TIMESTAMP, Timestamp.valueOf(createdTimeEnd))));
}

From source file:Main.java

  public void readData(RowSetInternal caller) throws SQLException {
  System.out.println("--- CustomRowSetReader: begin. ---");
  if (caller == null) {
    System.out.println("CustomRowSetReader: caller is null.");
    return;/*from   w ww  . j  a  va 2 s  . c o m*/
  }

  CachedRowSet crs = (CachedRowSet) caller;
  // CachedRowSet crs = (CachedRowSet) caller.getOriginal();

  RowSetMetaData rsmd = new RowSetMetaDataImpl();

  rsmd.setColumnCount(3);

  rsmd.setColumnType(1, Types.VARCHAR);
  rsmd.setColumnType(2, Types.INTEGER);
  rsmd.setColumnType(3, Types.VARCHAR);

  rsmd.setColumnName(1, "col1");
  rsmd.setColumnName(2, "col2");
  rsmd.setColumnName(3, "col3");

  crs.setMetaData(rsmd);
  System.out.println("CustomRowSetReader: crs.setMetaData( rsmd );");

  crs.moveToInsertRow();

  crs.updateString(1, "StringCol11");
  crs.updateInt(2, 1);
  crs.updateString(3, "StringCol31");
  crs.insertRow();
  System.out.println("CustomRowSetReader: crs.insertRow() 1");

  crs.updateString(1, "StringCol12");
  crs.updateInt(2, 2);
  crs.updateString(3, "StringCol32");
  crs.insertRow();
  System.out.println("CustomRowSetReader: crs.insertRow() 2");

  crs.moveToCurrentRow();
  crs.beforeFirst();
  displayRowSet(crs);
  crs.beforeFirst();
  // crs.acceptChanges();
  System.out.println("CustomRowSetReader: end.");
}

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

@Override
public int deleteCakeAndType(int cakeAndTypeId) {
    String SQL_QUERY = "DELETE FROM cakes_and_types WHERE CAKE_AND_TYPE_ID = ? ";
    int rowCount = jdbcTemplate.update(SQL_QUERY, new Object[] { cakeAndTypeId }, new int[] { Types.INTEGER });
    Logger.getLogger(CakeAndTypeDao.class.getName()).log(Level.SEVERE,
            "   : {0} .", rowCount);
    return rowCount;
}

From source file:eagle.storage.jdbc.criteria.TestTorque.java

public void testInsert() throws TorqueException {
    BasePeerImpl basePeer = new BasePeerImpl();
    basePeer.setDatabaseName("eagle");
    ColumnValues columnValues = new ColumnValues();
    columnValues.put(new ColumnImpl("unittest_testtsentity", "uuid"),
            new JdbcTypedValue(UUID.randomUUID().toString(), Types.VARCHAR));
    columnValues.put(new ColumnImpl("unittest_testtsentity", "field1"), new JdbcTypedValue(34, Types.INTEGER));
    basePeer.doInsert(columnValues);/*w w w.  j a va 2 s.c o  m*/
}

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

public int nextSecAppIdGen(CFSecurityAuthorization Authorization, CFSecurityClusterPKey PKey) {
    final String S_ProcName = "nextSecAppIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*w  ww .ja va  2  s . c  o m*/
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

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

From source file:com.nextep.designer.sqlgen.oracle.debug.ctrl.DebugMethod.java

@Override
public Object invokeMethod(Object... arg) {

    IConnection conn = (IConnection) arg[0];

    CallableStatement stmt = null;
    Thread debuggedThread = null;
    try {//from w  w  w . j  a va  2 s  .com
        // Initializing our target connection
        targetConn = CorePlugin.getConnectionService().connect(conn);
        //
        stmt = targetConn.prepareCall("ALTER SESSION SET PLSQL_DEBUG=TRUE"); //$NON-NLS-1$
        try {
            stmt.execute();
        } finally {
            CaptureHelper.safeClose(null, stmt);
        }

        stmt = targetConn.prepareCall("{ ? = CALL DBMS_DEBUG.INITIALIZE() }"); //$NON-NLS-1$
        try {
            stmt.registerOutParameter(1, Types.VARCHAR);
            stmt.execute();
            debugSessionID = stmt.getString(1);
        } catch (SQLException e) {
            throw new ErrorException(e);
        } finally {
            CaptureHelper.safeClose(null, stmt);
        }

        // Switching to debug mode
        stmt = targetConn.prepareCall("{ CALL DBMS_DEBUG.DEBUG_ON() }"); //$NON-NLS-1$
        try {
            stmt.execute();
        } finally {
            CaptureHelper.safeClose(null, stmt);
        }

        // Starting our target code
        debuggedThread = new Thread(new TargetRunnable(targetConn));
        debuggedThread.start();

        // Now that we have our ID, we initialize debug connection
        debugConn = CorePlugin.getConnectionService().connect(conn);
        // new Thread(new DebugRunnable(debugConn,debugSessionID)).start();

        stmt = debugConn.prepareCall("{ CALL DBMS_DEBUG.ATTACH_SESSION(?) }"); //$NON-NLS-1$
        try {
            stmt.setString(1, debugSessionID);
            stmt.execute();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            CaptureHelper.safeClose(null, stmt);
        }

        stmt = debugConn.prepareCall("{ ? = CALL DBMS_DEBUG.SYNCHRONIZE(?,0) }"); //$NON-NLS-1$
        try {
            stmt.registerOutParameter(1, Types.INTEGER);
            stmt.registerOutParameter(2, OracleTypes.OTHER, "DBMS_DEBUG.RUNTIME_INFO"); //$NON-NLS-1$
            stmt.execute();
            Object o = stmt.getObject(2);
            if (o != null) {

            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            CaptureHelper.safeClose(null, stmt);
        }
        // // Setting breakpoints
        // stmt =
        // debugConn.prepareCall("{ call adp_debug.set_breakpoint(p_line=>?, p_name=>?, p_body=>true) }");
        // try {
        // for(IBreakpoint bp : SQLEditorUIServices.getInstance().getBreakpoints()) {
        // stmt.setInt(1, bp.getLine());
        // stmt.setString(2,bp.getTarget().getName());
        // stmt.execute();
        // }
        // } catch( Exception e) {
        // e.printStackTrace();
        // } finally {
        // stmt.close();
        // }
        stmt = debugConn.prepareCall("{ ? = CALL DBMS_DEBUG.CONTINUE(?,0,46) }"); //$NON-NLS-1$
        stmt.registerOutParameter(1, Types.INTEGER);
        stmt.registerOutParameter(2, OracleTypes.OTHER, "DBMS_DEBUG.RUNTIME_INFO"); //$NON-NLS-1$

        try {
            stmt.execute();
            Struct struct = (Struct) stmt.getObject(2);
            Object[] attrs = struct.getAttributes();
            int line = (Integer) attrs[0];
            int terminated = (Integer) attrs[1];
            int breakpoint = (Integer) attrs[2];
            LOGGER.debug(
                    "Continued to line " + line + ", terminated=" + terminated + ", breakpoint=" + breakpoint);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            CaptureHelper.safeClose(null, stmt);
        }

    } catch (SQLException e) {
        if (debuggedThread != null) {
            debuggedThread.interrupt();
        }
        throw new ErrorException(e);
    } finally {
        try {
            if (debugConn != null) {
                debugConn.close();
            }
        } catch (SQLException e) {
            throw new ErrorException("Unable to properly close connection: " + e.getMessage(), e);
        }
    }

    return null;
}

From source file:de.ingrid.importer.udk.strategy.v1.IDCStrategy1_0_2_clean.java

protected void importDefaultCatalogData() throws Exception {

    if (log.isInfoEnabled()) {
        log.info("Creating default catalog...");
    }//  w  w w .java 2  s  .c o  m

    pSqlStr = "INSERT INTO t03_catalogue (id, cat_uuid, cat_name, partner_name , provider_name, country_code,"
            + "workflow_control, expiry_duration, create_time, mod_uuid, mod_time, language_code) VALUES "
            + "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

    PreparedStatement p = jdbc.prepareStatement(pSqlStr);

    sqlStr = "DELETE FROM t03_catalogue";
    jdbc.executeUpdate(sqlStr);

    String currentTime = IDCStrategyHelper.transDateTime(new Date());

    int cnt = 1;
    dataProvider.setId(dataProvider.getId() + 1);
    p.setLong(cnt++, dataProvider.getId()); // id
    p.setString(cnt++, UuidGenerator.getInstance().generateUuid()); // cat_uuid
    p.setString(cnt++, getImportDescriptor().getIdcCatalogueName()); // cat_name
    p.setString(cnt++, getImportDescriptor().getIdcPartnerName()); // partner_name
    p.setString(cnt++, getImportDescriptor().getIdcProviderName()); // provider_name
    p.setString(cnt++, getImportDescriptor().getIdcCatalogueCountry()); // country_code
    p.setString(cnt++, "N"); // workflow_control
    p.setNull(cnt++, Types.INTEGER); // expiry_duration
    p.setString(cnt++, currentTime); // create_time

    String modUuid = null;
    String modTime = null;

    String sql = "SELECT adr_uuid FROM t02_address";
    Statement st = jdbc.createStatement();
    ResultSet rs = jdbc.executeQuery(sql, st);
    if (rs.next()) {
        modUuid = rs.getString("adr_uuid");
        if (modUuid != null) {
            modTime = currentTime;
        }
    }
    rs.close();
    st.close();

    p.setString(cnt++, modUuid); // mod_uuid,
    p.setString(cnt++, modTime); // mod_time
    p.setString(cnt++, getCatalogLanguageFromDescriptor()); // language_code
    try {
        p.executeUpdate();
    } catch (Exception e) {
        log.error("Error executing SQL: " + p.toString(), e);
        throw e;
    }

    if (log.isInfoEnabled()) {
        log.info("Creating default catalog... done.");
    }
}

From source file:com.cloudera.sqoop.mapreduce.db.DataDrivenDBInputFormat.java

/**
 * @return the DBSplitter implementation to use to divide the table/query
 * into InputSplits./*from  ww  w  .  jav a  2  s  .  com*/
 */
protected DBSplitter getSplitter(int sqlDataType) {
    switch (sqlDataType) {
    case Types.NUMERIC:
    case Types.DECIMAL:
        return new BigDecimalSplitter();

    case Types.BIT:
    case Types.BOOLEAN:
        return new BooleanSplitter();

    case Types.INTEGER:
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.BIGINT:
        return new IntegerSplitter();

    case Types.REAL:
    case Types.FLOAT:
    case Types.DOUBLE:
        return new FloatSplitter();

    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return new TextSplitter();

    case Types.DATE:
    case Types.TIME:
    case Types.TIMESTAMP:
        return new DateSplitter();

    default:
        // TODO: Support BINARY, VARBINARY, LONGVARBINARY, DISTINCT, CLOB,
        // BLOB, ARRAY, STRUCT, REF, DATALINK, and JAVA_OBJECT.
        return null;
    }
}

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

@Test
public void testNewColumn() throws Exception {
    HiveMetadataProcessor processor = new HiveMetadataProcessorBuilder().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));
    Record record = RecordCreator.create("s", "s:1");
    record.set(Field.create(map));
    records.add(record);//from w  ww  .j  ava  2 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"));
    record = RecordCreator.create("s", "s:1");
    record.set(Field.create(map));
    records.add(record);

    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.new_column", Types.VARCHAR),
                    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(null, rs.getString(2));

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

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