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:org.waarp.common.database.data.AbstractDbData.java
/** * Create the equivalent object in Json (no database access) * /* w w w .j a v a2 s . co m*/ * @return The ObjectNode Json equivalent */ public ObjectNode getJson() { ObjectNode node = JsonHandler.createObjectNode(); node.put(JSON_MODEL, this.getClass().getSimpleName()); for (DbValue value : allFields) { if (value.column.equalsIgnoreCase("UPDATEDINFO")) { continue; } switch (value.type) { case Types.VARCHAR: case Types.LONGVARCHAR: node.put(value.column, (String) value.value); break; case Types.BIT: node.put(value.column, (Boolean) value.value); break; case Types.TINYINT: node.put(value.column, (Byte) value.value); break; case Types.SMALLINT: node.put(value.column, (Short) value.value); break; case Types.INTEGER: node.put(value.column, (Integer) value.value); break; case Types.BIGINT: node.put(value.column, (Long) value.value); break; case Types.REAL: node.put(value.column, (Float) value.value); break; case Types.DOUBLE: node.put(value.column, (Double) value.value); break; case Types.VARBINARY: node.put(value.column, (byte[]) value.value); break; case Types.DATE: node.put(value.column, ((Date) value.value).getTime()); break; case Types.TIMESTAMP: node.put(value.column, ((Timestamp) value.value).getTime()); break; case Types.CLOB: case Types.BLOB: default: node.put(value.column, "Unsupported type=" + value.type); } } return node; }
From source file:ca.sqlpower.sqlobject.TestSQLTable.java
public void testAddColAbovePK() throws SQLObjectException { table.addColumn(new SQLColumn(table, "indextwo", Types.INTEGER, 10, 0), 2); assertEquals(7, table.getColumns().size()); assertEquals(4, table.getPkSize());/* w ww . jav a 2 s .co m*/ assertTrue(table.getColumnByName("indextwo").isPrimaryKey()); assertEquals(0, table.getColumnIndex(table.getColumnByName("one"))); assertEquals(1, table.getColumnIndex(table.getColumnByName("two"))); assertEquals(2, table.getColumnIndex(table.getColumnByName("indextwo"))); assertEquals(3, table.getColumnIndex(table.getColumnByName("three"))); assertEquals(4, table.getColumnIndex(table.getColumnByName("four"))); assertEquals(5, table.getColumnIndex(table.getColumnByName("five"))); assertEquals(6, table.getColumnIndex(table.getColumnByName("six"))); }
From source file:com.mirth.connect.donkey.server.data.jdbc.JdbcDao.java
private void updateStatistics(String channelId, Integer metaDataId, Map<Status, Long> stats) { long received = stats.get(Status.RECEIVED); long filtered = stats.get(Status.FILTERED); long sent = stats.get(Status.SENT); long error = stats.get(Status.ERROR); logger.debug(channelId + "/" + metaDataId + ": saving statistics"); PreparedStatement statement;/*from www. jav a 2 s . c o m*/ try { if (metaDataId == null) { statement = prepareStatement("updateChannelStatistics", channelId); } else { statement = prepareStatement("updateConnectorStatistics", channelId); } statement.setLong(1, received); statement.setLong(2, received); statement.setLong(3, filtered); statement.setLong(4, filtered); statement.setLong(5, sent); statement.setLong(6, sent); statement.setLong(7, error); statement.setLong(8, error); if (metaDataId != null) { statement.setInt(9, metaDataId); statement.setString(10, statsServerId); } else { statement.setString(9, statsServerId); } if (statement.executeUpdate() == 0) { statement = prepareStatement("insertChannelStatistics", channelId); if (metaDataId == null) { statement.setNull(1, Types.INTEGER); } else { statement.setInt(1, metaDataId); } statement.setString(2, statsServerId); statement.setLong(3, received); statement.setLong(4, received); statement.setLong(5, filtered); statement.setLong(6, filtered); statement.setLong(7, sent); statement.setLong(8, sent); statement.setLong(9, error); statement.setLong(10, error); statement.executeUpdate(); } } catch (SQLException e) { throw new DonkeyDaoException(e); } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ?????// w w w .j a va 2s. c om * @param declNo * @return */ public static int checkDeclProductPerfect(String declNo) { int retCode = -1; Connection conn = null; CallableStatement proc = null; ResultSet rs = null; String call = "{call Pro_CheckDeclProductPerfect(?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.registerOutParameter(2, Types.INTEGER); proc.execute(); retCode = proc.getInt(2); } catch (SQLException e) { // TODO Auto-generated catch block log.error(e); } catch (Exception e) { log.error(e); } finally { try { if (rs != null) { rs.close(); } if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error(e); } } return retCode; }
From source file:architecture.user.dao.impl.ExternalJdbcUserDao.java
public List<User> getUsers(Company company, int startIndex, int numResults) { List<User> users = getExtendedJdbcTemplate().queryScrollable(getSql("SELECT_ALL_COMPANY_VISIBLE_USER"), startIndex, numResults, new Object[] { company.getCompanyId() }, new int[] { Types.INTEGER }, userMapper);/* w w w .ja va2s . c om*/ for (User user : users) { try { ((UserTemplate) user).setCompany(CompanyUtils.getCompany(user.getCompanyId())); } catch (CompanyNotFoundException e) { } ((UserTemplate) user).setProperties(this.getUserProperties(user.getUserId())); } return users; }
From source file:ca.sqlpower.sqlobject.TestSQLTable.java
public void testAddColBelowPK() throws SQLObjectException { table.addColumn(new SQLColumn(table, "indexfour", Types.INTEGER, 10, 0), 4); assertEquals(7, table.getColumns().size()); assertEquals(3, table.getPkSize());/*from ww w . j ava 2 s .c o m*/ assertFalse(table.getColumnByName("indexfour").isPrimaryKey()); assertEquals(0, table.getColumnIndex(table.getColumnByName("one"))); assertEquals(1, table.getColumnIndex(table.getColumnByName("two"))); assertEquals(2, table.getColumnIndex(table.getColumnByName("three"))); assertEquals(3, table.getColumnIndex(table.getColumnByName("four"))); assertEquals(4, table.getColumnIndex(table.getColumnByName("indexfour"))); assertEquals(5, table.getColumnIndex(table.getColumnByName("five"))); assertEquals(6, table.getColumnIndex(table.getColumnByName("six"))); }
From source file:com.netspective.axiom.sql.StoredProcedureParameter.java
/** * @param vrc/*from ww w .j a v a 2 s . c o m*/ * @param cc * * @throws SQLException */ public void retrieve(StoredProcedureParameters.ValueRetrieveContext vrc, ConnectionContext cc) throws SQLException { // TODO: This needs to be tested.. no checking for stored procedure situation yet int jdbcType = getSqlType().getJdbcType(); if (jdbcType != Types.ARRAY) { if (jdbcType == Types.VARCHAR) { vrc.addInOutValue(value != null ? value.getTextValue(cc) : null, jdbcType, type); } else { switch (jdbcType) { case Types.INTEGER: vrc.addInOutValue(value != null ? new Integer(value.getValue(cc).getIntValue()) : null, jdbcType, type); break; case Types.DOUBLE: vrc.addInOutValue(value != null ? new Double(value.getValue(cc).getDoubleValue()) : null, jdbcType, type); break; } } } else { if (value != null && type.getValueIndex() == Type.IN) { String[] textValues = value.getTextValues(cc); for (int q = 0; q < textValues.length; q++) vrc.addInOutValue(textValues[q], Types.VARCHAR, type); } } }
From source file:fr.aliacom.obm.common.calendar.CalendarDaoJdbcImpl.java
private int fillEventStatement(PreparedStatement ps, Event ev, AccessToken at, int i) throws SQLException { int idx = i;/*from w w w.j ava2 s . c om*/ ps.setString(idx++, ev.getExtId().getExtId()); ps.setString(idx++, ev.getTimezoneName()); ps.setObject(idx++, obmHelper.getDBCP().getJdbcObject(ObmHelper.VOPACITY, ev.getOpacity().toString())); ps.setString(idx++, ev.getTitle()); ps.setString(idx++, ev.getLocation()); Integer cat = catIdFromString(ps.getConnection(), ev.getCategory(), at.getDomain().getId()); if (cat != null) { ps.setInt(idx++, cat); } else { ps.setNull(idx++, Types.INTEGER); } ps.setInt(idx++, RFC2445.getPriorityOrDefault(ev.getPriority())); ps.setInt(idx++, ev.getPrivacy().toInteger()); if (ev.getStartDate() != null) { ps.setTimestamp(idx++, new Timestamp(ev.getStartDate().getTime())); } else { ps.setNull(idx++, Types.DATE); } ps.setInt(idx++, ev.getDuration()); ps.setBoolean(idx++, ev.isAllday()); EventRecurrence r = ev.getRecurrence(); ps.setString(idx++, r.getKind().toString()); ps.setInt(idx++, r.getFrequence()); ps.setString(idx++, new RecurrenceDaysSerializer().serialize(r.getDays())); if (r.getEnd() != null) { ps.setTimestamp(idx++, new Timestamp(r.getEnd().getTime())); } else { ps.setNull(idx++, Types.DATE); } ps.setNull(idx++, Types.VARCHAR); // color ps.setNull(idx++, Types.DATE); // FIXME completed ps.setNull(idx++, Types.VARCHAR); // FIXME url ps.setString(idx++, ev.getDescription()); ps.setInt(idx++, at.getDomain().getId()); ps.setString(idx++, at.getOrigin()); ps.setObject(idx++, obmHelper.getDBCP().getJdbcObject(ObmHelper.VCOMPONENT, ev.getType().toString())); ps.setInt(idx++, ev.getSequence()); return idx; }
From source file:architecture.ee.web.community.page.dao.jdbc.JdbcPageDao.java
private void updatePageBody(Page page, int prevVersionId) { long bodyId = -1L; try {/*w w w . jav a 2s. c o m*/ bodyId = getExtendedJdbcTemplate().queryForObject( getBoundSql("ARCHITECTURE_COMMUNITY.SELETE_PAGE_BODY_ID").getSql(), Long.class, new SqlParameterValue(Types.NUMERIC, page.getPageId()), new SqlParameterValue(Types.NUMERIC, prevVersionId)); } catch (EmptyResultDataAccessException e) { } if (page.getBodyText() != null) { if (bodyId != -1L) { final long bodyIdToUse = bodyId; getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_COMMUNITY.UPDATE_PAGE_BODY").getSql(), new SqlParameterValue(Types.INTEGER, page.getBodyContent().getBodyType().getId()), new SqlParameterValue(Types.VARCHAR, page.getBodyContent().getBodyText()), new SqlParameterValue(Types.NUMERIC, bodyIdToUse)); } else { final long bodyIdToUse = getNextId("PAGE_BODY"); getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_COMMUNITY.INSERT_PAGE_BODY").getSql(), new SqlParameterValue(Types.NUMERIC, bodyIdToUse), new SqlParameterValue(Types.NUMERIC, page.getPageId()), new SqlParameterValue(Types.INTEGER, page.getBodyContent().getBodyType().getId()), new SqlParameterValue(Types.VARCHAR, page.getBodyContent().getBodyText())); getExtendedJdbcTemplate().update( getBoundSql("ARCHITECTURE_COMMUNITY.INSERT_PAGE_BODY_VERSION").getSql(), new SqlParameterValue(Types.NUMERIC, bodyId), new SqlParameterValue(Types.NUMERIC, page.getPageId()), new SqlParameterValue(Types.NUMERIC, prevVersionId)); } } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
public static int checkDeclProductSampling(String declNo) { int retCode = -1; Connection conn = null;/*from ww w .j a v a 2 s .c o m*/ CallableStatement proc = null; ResultSet rs = null; String call = "{call Pro_CheckDeclProductSampling(?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, declNo); proc.registerOutParameter(2, Types.INTEGER); proc.execute(); retCode = proc.getInt(2); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N57", e); } catch (Exception e) { log.error("N58", e); } finally { try { if (rs != null) { rs.close(); } if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N59", e); } } return retCode; }