List of usage examples for java.sql Types INTEGER
int INTEGER
To view the source code for java.sql Types INTEGER.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type INTEGER
.
From source file:com.streamsets.pipeline.stage.executor.jdbc.TestJdbcQueryExecutor.java
@Test public void testExecuteSimpleQuery() throws Exception { JdbcQueryExecutor queryExecutor = createExecutor("CREATE TABLE copy AS SELECT * FROM origin"); ExecutorRunner runner = new ExecutorRunner.Builder(JdbcQueryDExecutor.class, queryExecutor) .setOnRecordError(OnRecordError.STOP_PIPELINE).build(); runner.runInit();//from w ww.j a v a2s. c om Record record = RecordCreator.create(); record.set(Field.create("blank line")); runner.runWrite(ImmutableList.of(record)); runner.runDestroy(); assertTableStructure("copy", new ImmutablePair("ID", Types.INTEGER), new ImmutablePair("NAME", Types.VARCHAR)); }
From source file:konditer_reorganized_database.dao.GenIdDao.java
public int getId(String tableName) throws SQLException { String SQL_QUERY_1 = "SELECT ROW_COUNT FROM cake_portal.gen_id WHERE TABLE_NAME = ?"; String SQL_QUERY_2 = "UPDATE cake_portal.gen_id SET ROW_COUNT = ? WHERE TABLE_NAME = ?"; GenId genId = (GenId) jdbcTemplate.queryForObject(SQL_QUERY_1, new Object[] { tableName }, new BeanPropertyRowMapper(GenId.class)); newId = genId.getRowCount() + 1;/* w w w .j a v a 2 s .co m*/ jdbcTemplate.update(SQL_QUERY_2, new Object[] { newId, tableName }, new int[] { Types.INTEGER, Types.VARCHAR }); return newId; }
From source file:io.lightlink.oracle.AbstractOracleType.java
protected ARRAY createArray(Connection con, Object value, String typeName) throws SQLException { if (value == null) return null; ArrayDescriptor arrayStructDesc = safeCreateArrayDescriptor(typeName, con); if (value == null) return null; if (value.getClass().isArray()) { value = Arrays.asList((Object[]) value); }// w ww . j ava 2 s . c om List records = (List) value; String baseName = arrayStructDesc.getBaseName(); int baseType = arrayStructDesc.getBaseType(); if (baseType == Types.VARCHAR || baseType == Types.CHAR || baseType == Types.CLOB || baseType == Types.NUMERIC || baseType == Types.INTEGER || baseType == Types.BIGINT || baseType == Types.FLOAT || baseType == Types.DOUBLE || baseType == Types.DECIMAL || baseType == Types.NCHAR || baseType == Types.NVARCHAR || baseType == Types.NCLOB) { return new ARRAY(arrayStructDesc, con, records.toArray()); // primitive array } else { Object[] structArray = new Object[records.size()]; for (int i = 0; i < structArray.length; i++) { Object record = records.get(i); if (baseType == OracleTypes.JAVA_STRUCT || baseType == OracleTypes.JAVA_OBJECT || baseType == OracleTypes.STRUCT || baseType == OracleTypes.JAVA_STRUCT) { record = createStruct(con, record, baseName); } else if (baseType == OracleTypes.ARRAY) { record = createArray(con, record, baseName); } structArray[i] = record; } return new ARRAY(arrayStructDesc, con, structArray); } }
From source file:com.squid.kraken.v4.caching.redis.datastruct.RawMatrix.java
public static RawMatrix getTestMatrix() { RawMatrix test = new RawMatrix(); test.colNames.add("string column"); test.colNames.add("int column"); test.colTypes.add(java.sql.Types.VARCHAR); test.colTypes.add(java.sql.Types.INTEGER); int i = 0;/* www . j a v a 2s . c om*/ // init row while (i < 10) { Object[] r = new Object[2]; test.addRow(new RawRow(r)); i++; } i = 0; while (i < 10) { test.rows.get(i).data[0] = new String("abc" + i); test.rows.get(i).data[1] = new Integer(i); i++; } return test; }
From source file:com.streamsets.pipeline.stage.destination.hive.queryexecutor.HiveQueryExecutorIT.java
@Test public void testEL() throws Exception { HiveQueryExecutor queryExecutor = createExecutor( "CREATE TABLE ${record:value('/table')} AS SELECT * FROM origin"); TargetRunner runner = new TargetRunner.Builder(HiveQueryDExecutor.class, queryExecutor) .setOnRecordError(OnRecordError.STOP_PIPELINE).build(); runner.runInit();/*from w ww . j a v a 2s . c o m*/ Map<String, Field> map = new HashMap<>(); map.put("table", Field.create("el")); Record record = RecordCreator.create(); record.set(Field.create(map)); runner.runWrite(ImmutableList.of(record)); runner.runDestroy(); assertTableStructure("default.el", new ImmutablePair("el.id", Types.INTEGER), new ImmutablePair("el.name", Types.VARCHAR)); }
From source file:net.sourceforge.vulcan.spring.jdbc.HistoryQueryBuilder.java
static void buildQuery(String selectClause, BuildOutcomeQueryDto dto, BuilderQuery query) { final Set<String> projectNames = dto.getProjectNames(); if (projectNames == null || projectNames.isEmpty()) { throw new IllegalArgumentException("Must query for at least one project name"); }// w ww. ja v a 2 s .c o m final List<? super Object> params = new ArrayList<Object>(); final StringBuilder sb = new StringBuilder(); sb.append("where project_names.name"); query.declareParameter(new SqlParameter(Types.VARCHAR)); if (projectNames.size() == 1) { sb.append("=?"); params.addAll(projectNames); } else { sb.append(" in (?"); for (int i = 1; i < projectNames.size(); i++) { sb.append(",?"); query.declareParameter(new SqlParameter(Types.VARCHAR)); } sb.append(")"); final List<String> sorted = new ArrayList<String>(projectNames); Collections.sort(sorted); params.addAll(sorted); } if (dto.getMinDate() != null) { sb.append(" and completion_date>=?"); params.add(dto.getMinDate()); query.declareParameter(new SqlParameter(Types.TIMESTAMP)); } if (dto.getMaxDate() != null) { sb.append(" and completion_date<?"); params.add(dto.getMaxDate()); query.declareParameter(new SqlParameter(Types.TIMESTAMP)); } if (dto.getMinBuildNumber() != null) { sb.append(" and build_number>=?"); params.add(dto.getMinBuildNumber()); query.declareParameter(new SqlParameter(Types.INTEGER)); } if (dto.getMaxBuildNumber() != null) { sb.append(" and build_number<=?"); params.add(dto.getMaxBuildNumber()); query.declareParameter(new SqlParameter(Types.INTEGER)); } final Set<Status> statuses = dto.getStatuses(); if (statuses != null && !statuses.isEmpty()) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(" and status in (?"); for (int i = 1; i < statuses.size(); i++) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(",?"); } sb.append(")"); params.addAll(statuses); } if (dto.getUpdateType() != null) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(" and update_type=?"); params.add(dto.getUpdateType().name()); } if (isNotBlank(dto.getRequestedBy())) { query.declareParameter(new SqlParameter(Types.VARCHAR)); sb.append(" and requested_by=?"); params.add(dto.getRequestedBy()); } query.setParameterValues(params.toArray()); query.setSql(selectClause + sb.toString()); }
From source file:com.wso2telco.dep.ratecardservice.dao.RateCategoryDAO.java
public RateCategoryDTO addRateCategory(RateCategoryDTO rateCategory) throws BusinessException { Connection con = null;// w ww . ja v a 2s. c o m PreparedStatement ps = null; ResultSet rs = null; Integer rateCategoryId = 0; try { con = DbUtils.getDbConnection(DataSourceNames.WSO2TELCO_RATE_DB); if (con == null) { log.error("unable to open " + DataSourceNames.WSO2TELCO_RATE_DB + " database connection"); throw new BusinessException(ServiceError.SERVICE_ERROR_OCCURED); } StringBuilder query = new StringBuilder("insert into "); query.append(DatabaseTables.RATE_CATEGORY.getTObject()); query.append(" (rate_defid, parentcategoryid, childcategoryid, tariffid, createdby)"); query.append(" values"); query.append(" (?, ?, ?, ?, ?)"); ps = con.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS); log.debug("sql query in addRateCategory : " + ps); ps.setInt(1, rateCategory.getRateDefinition().getRateDefId()); ps.setInt(2, rateCategory.getCategory().getCategoryId()); Integer subCategoryId = rateCategory.getSubCategory().getCategoryId(); if (subCategoryId != null) { ps.setInt(3, subCategoryId); } else { ps.setNull(3, Types.INTEGER); } ps.setInt(4, rateCategory.getTariff().getTariffId()); ps.setString(5, rateCategory.getCreatedBy()); ps.executeUpdate(); rs = ps.getGeneratedKeys(); while (rs.next()) { rateCategoryId = rs.getInt(1); } rateCategory.setRateCategoryId(rateCategoryId); } catch (SQLException e) { log.error("database operation error in addRateCategory : ", e); throw new BusinessException(ServiceError.SERVICE_ERROR_OCCURED); } catch (Exception e) { log.error("error in addRateCategory : ", e); throw new BusinessException(ServiceError.SERVICE_ERROR_OCCURED); } finally { DbUtils.closeAllConnections(ps, con, rs); } return rateCategory; }
From source file:com.cloudera.sqoop.manager.TestSqlManager.java
@Test public void testListColTypes() { Map<String, Integer> types = manager.getColumnTypes(HsqldbTestServer.getTableName()); assertNotNull("manager returned no types map", types); assertEquals("Map should be size=2", 2, types.size()); assertEquals(types.get("INTFIELD1").intValue(), Types.INTEGER); assertEquals(types.get("INTFIELD2").intValue(), Types.INTEGER); }
From source file:com.tesora.dve.common.TestDataGenerator.java
protected Object getColumnValue(ColumnMetadata cm) { Object cv = null;// ww w . java 2 s . com Calendar cal = Calendar.getInstance(); switch (cm.getDataType()) { case Types.BIT: case Types.BOOLEAN: cv = Boolean.TRUE; break; case Types.BIGINT: cv = Long.MAX_VALUE; break; case Types.CHAR: case Types.VARCHAR: cv = StringUtils.left(baseString, cm.getSize()); break; case Types.SMALLINT: cv = Short.MAX_VALUE; break; case Types.TINYINT: cv = Byte.MAX_VALUE; break; case Types.INTEGER: cv = Integer.MAX_VALUE; break; case Types.DOUBLE: cv = new Double(1234.5678); // TODO need to handle s,p break; case Types.FLOAT: cv = new Float(123.56); // TODO need to handle s,p break; case Types.DECIMAL: cv = new BigDecimal("12345.6789"); // TODO need to handle s,p break; case Types.DATE: cal.setTimeInMillis(123456789); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); cv = cal.getTime(); break; case Types.TIMESTAMP: cal.setTimeInMillis(123456789); cv = cal.getTime(); break; case Types.TIME: cv = new Time(123456789); break; default: break; } return cv; }
From source file:konditer.client.dao.CustomerDao.java
@Override public void addCustomer(int customerId, int discountId, String customerFirstName) { 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 {/* ww w . jav a 2 s. co m*/ rowCount = jdbcTemplate.update(SQL_QUERY, new Object[] { customerId, discountId, "", customerFirstName, "", new Date(), "" }, 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 + "\n" + customerDao.getCustomer(customerId).toString()); } catch (DataAccessException e) { rowCount = 0; Logger.getLogger(CustomerDao.class.getName()).log(Level.SEVERE, " . ?: {0} .", rowCount); } }