List of usage examples for java.sql ResultSet getTimestamp
java.sql.Timestamp getTimestamp(String columnLabel) throws SQLException;
ResultSet
object as a java.sql.Timestamp
object in the Java programming language. From source file:dsd.dao.WorstCaseDAO.java
public static ArrayList<WorstPylonCase> GetAllForPeriod(Calendar startDate, Calendar endDate, boolean traffic, boolean debris) { try {/*from ww w. ja v a 2 s. c o m*/ Connection con = DAOProvider.getDataSource().getConnection(); ArrayList<WorstPylonCase> worstCaseDataList = new ArrayList<WorstPylonCase>(); try { String tableName = GetTableNameForDataType(traffic, debris); Object[] parameters = new Object[2]; parameters[0] = new Timestamp(startDate.getTimeInMillis()); parameters[1] = new Timestamp(endDate.getTimeInMillis()); ResultSet results = DAOProvider.SelectTableSecure(tableName, "*", " timestamp >= ? and timestamp <= ? ", "", con, parameters); while (results.next()) { WorstPylonCase dataTuple = new WorstPylonCase(results.getInt(fields[0])); Pylon pylon = new Pylon(results.getInt(fields[0])); pylon.setN(results.getFloat(fields[1])); pylon.setTx(results.getFloat(fields[2])); pylon.setTy(results.getFloat(fields[3])); pylon.setMx(results.getFloat(fields[4])); pylon.setMy(results.getFloat(fields[5])); pylon.setM(results.getFloat(fields[6])); dataTuple.setPylon(pylon); dataTuple.setID(results.getLong("ID")); dataTuple.setComboNumber(results.getInt(fields[8])); dataTuple.setSafetyFactor(results.getFloat(fields[7])); dataTuple.setTimestamp(results.getTimestamp(fields[9]).getTime()); worstCaseDataList.add(dataTuple); } } catch (Exception exc) { exc.printStackTrace(); } con.close(); return worstCaseDataList; } catch (Exception exc) { exc.printStackTrace(); } return null; }
From source file:com.healthcit.analytics.dao.rowmapper.ReportTemplateRowMapper.java
@Override public ReportTemplate mapRow(ResultSet resultSet, int rowNum) throws SQLException { ReportTemplate template = new ReportTemplate(resultSet.getLong(ID_COLUMN), resultSet.getString(TITLE_COLUMN), resultSet.getString(REPORT_COLUMN), resultSet.getTimestamp(TIMESTAMP_COLUMN), resultSet.getLong(OWNER_ID_COLUMN), resultSet.getBoolean(SHARED_COLUMN)); try {/*from ww w . j ava2s .c o m*/ resultSet.findColumn(USERNAME_COLUMN); template.setOwnerName(resultSet.getString(USERNAME_COLUMN)); } catch (SQLException ex) { } return template; }
From source file:cc.cicadabear.profile.infrastructure.jdbc.UserRowMapper.java
@Override public User mapRow(ResultSet rs, int i) throws SQLException { User user = new User(); user.id(rs.getInt("id")); user.guid(rs.getString("guid")); user.archived(rs.getBoolean("archived")); user.createTime(rs.getTimestamp("create_time").toLocalDateTime()); user.email(rs.getString("email")); user.phone(rs.getString("phone")); user.password(rs.getString("password")); user.salt(rs.getString("salt")); user.setLocked(rs.getInt("locked")); user.setStatus(rs.getInt("status")); user.username(rs.getString("username")); user.lastLoginTime(rs.getTimestamp("last_login_time")); return user;// ww w. j ava 2 s. c o m }
From source file:net.freechoice.model.orm.Map_Comment.java
@Override public FC_Comment mapRow(final ResultSet rs, int rowNum) throws SQLException { FC_Comment comment = new FC_Comment(); comment.id = rs.getInt(1);// w w w . ja v a 2 s . c o m comment.id_post_ = rs.getInt(2); comment.time_posted = rs.getTimestamp(3); comment.email = rs.getString(4); comment.name = rs.getString(5); comment.comment = rs.getString(6); return comment; }
From source file:com.persistent.cloudninja.mapper.WebLogMeteringBatchRowMapper.java
@Override public WebLogMeteringBatch mapRow(ResultSet rs, int rowNum) throws SQLException { WebLogMeteringBatch webLogMeteringBatchRowMapper = new WebLogMeteringBatch(); webLogMeteringBatchRowMapper.setLogUri(rs.getString("LogUri")); webLogMeteringBatchRowMapper.setLastUpdatedTime(rs.getTimestamp("LastUpdatedTime")); webLogMeteringBatchRowMapper.setLastLineProcessed(rs.getInt("LastLineProcessed")); return webLogMeteringBatchRowMapper; }
From source file:com.genie.service.UserDao.java
public User getUser(String id) { List<User> users = this.jdbcTemplate.query(SELECT_USER_BY_ID, (ResultSet rs, int rowNum) -> { User user = new User(); user.setId(rs.getString("id")); user.setName(rs.getString("name")); user.setPassword(rs.getString("password")); user.setCreatedTime(rs.getTimestamp("created_at")); user.setUpdatedTime(rs.getTimestamp("updated_at")); return user; }, id);/*from ww w. j av a 2s . c o m*/ return users.isEmpty() ? null : users.get(0); }
From source file:com.oltpbenchmark.benchmarks.auctionmark.AuctionMarkProfile.java
private static final void loadItems(AuctionMarkProfile profile, ResultSet vt) throws SQLException { int ctr = 0;//from w ww.j a v a 2 s .c o m while (vt.next()) { int col = 1; ItemId i_id = new ItemId(vt.getLong(col++)); double i_current_price = vt.getDouble(col++); Timestamp i_end_date = vt.getTimestamp(col++); int i_num_bids = (int) vt.getLong(col++); // IMPORTANT: Do not set the status here so that we make sure that // it is added to the right queue ItemInfo itemInfo = new ItemInfo(i_id, i_current_price, i_end_date, i_num_bids); profile.addItemToProperQueue(itemInfo, false); ctr++; } // WHILE if (LOG.isDebugEnabled()) LOG.debug(String.format("Loaded %d records from %s", ctr, AuctionMarkConstants.TABLENAME_ITEM)); }
From source file:net.freechoice.model.orm.Map_Transaction.java
@Override public FC_Transaction mapRow(final ResultSet rs, int rowNum) throws SQLException { FC_Transaction transaction = new FC_Transaction(); transaction.id = rs.getInt(1);//from ww w. j a v a 2 s .c o m transaction.id_account_ = rs.getInt(2); transaction.time_committed = rs.getTimestamp(3); transaction.amount = rs.getBigDecimal(4); transaction.comment = rs.getString(5); return transaction; }
From source file:net.solarnetwork.node.dao.jdbc.power.test.JdbcPowerDatumDaoTest.java
@Test public void storeNew() { PowerDatum datum = new PowerDatum(); datum.setCreated(new Date()); datum.setWatts(TEST_WATTS);/*from ww w. j a v a 2 s . c om*/ datum.setSourceId(TEST_SOURCE_ID); datum.setWattHourReading(TEST_WATT_HOURS); dao.storeDatum(datum); jdbcOps.query(SQL_GET_BY_ID, new Object[] { datum.getCreated(), datum.getSourceId() }, new ResultSetExtractor<Object>() { @Override public Object extractData(ResultSet rs) throws SQLException, DataAccessException { assertTrue("Must have one result", rs.next()); int col = 1; rs.getTimestamp(col++); assertFalse(rs.wasNull()); String s = rs.getString(col++); assertFalse(rs.wasNull()); assertEquals(TEST_SOURCE_ID, s); int w = rs.getInt(col++); assertFalse(rs.wasNull()); assertEquals(TEST_WATTS.intValue(), w); long wh = rs.getLong(col++); assertFalse(rs.wasNull()); assertEquals(TEST_WATT_HOURS.longValue(), wh); assertFalse("Must not have more than one result", rs.next()); return null; } }); }
From source file:tianci.pinao.dts.dao.impl.ConfigDaoImpl.java
@Override public Config mapRow(ResultSet rs, int index) throws SQLException { Config config = new Config(); config.setId(rs.getInt("id")); config.setType(rs.getInt("type")); config.setValue(rs.getLong("value")); Timestamp ts = rs.getTimestamp("lastmod_time"); if (ts != null) config.setLastModTime(new Date(ts.getTime())); config.setLastModUserid(rs.getInt("lastmod_userid")); return config; }