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:pl.edu.agh.samm.db.impl.mapper.MeasurementValueRowMapper.java
@Override public MeasurementValue mapRow(ResultSet rs, int arnrg1) throws SQLException { MeasurementValue mv = new MeasurementValue(); mv.setCapabilityUri(rs.getString("capability_uri")); mv.setId(rs.getLong("id")); mv.setInstanceUri(rs.getString("instance_uri")); mv.setTimestamp(new Date(rs.getTimestamp("timestamp").getTime())); // FIXME // why//from w w w . jav a 2 s . c o m // the // heck // is // has // to // be // like // that? // HSQL's // fault? mv.setValue(rs.getDouble("value")); return mv; }
From source file:com.simpletasks.dao.impl.jdbc.TaskMapper.java
public Task mapRow(ResultSet resultSet, int i) throws SQLException { Task task = new Task(); task.setId(resultSet.getInt(1));//from ww w . ja va 2s .com task.setTitle(resultSet.getString(3)); task.setDetail(resultSet.getString(4)); task.setFinished(resultSet.getBoolean(5)); task.setCreateDate(DaoUtil.getDate(resultSet.getTimestamp(6))); task.setEndDate(DaoUtil.getDate(resultSet.getTimestamp(7))); return task; }
From source file:net.chrisrichardson.bankingExample.domain.jdbc.JdbcAccountDao.java
public Account findAccount(String accountId) { logger.debug("finding account"); return (Account) jdbcTemplate.queryForObject("SELECT * FROM BANK_ACCOUNT WHERE accountId = ?", new Object[] { accountId }, new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { return new Account(rs.getInt("ACCOUNT_ID"), rs.getString("accountId"), rs.getDouble("BALANCE"), rs.getInt("overdraftPolicy"), new Date(rs.getTimestamp("dateOpened").getTime()), rs.getDouble("requiredYearsOpen"), rs.getDouble("limit")); }//from w ww . j a va2s . c o m }); }
From source file:tianci.pinao.dts.dao.impl.ConfigDaoImpl.java
@Override public License mapRow(ResultSet rs, int index) throws SQLException { License license = new License(); license.setId(rs.getInt("id")); license.setMac(rs.getString("mac")); license.setUseTime(rs.getLong("use_time")); Timestamp ts = rs.getTimestamp("lastmod_time"); if (ts != null) license.setLastModTime(new Date(ts.getTime())); license.setLastModUserid(rs.getInt("lastmod_userid")); return license; }
From source file:com.oltpbenchmark.benchmarks.auctionmark.AuctionMarkProfile.java
private static final void loadConfigProfile(AuctionMarkProfile profile, ResultSet vt) throws SQLException { boolean adv = vt.next(); assert (adv) : String.format("Failed to get data from %s\n%s", AuctionMarkConstants.TABLENAME_CONFIG_PROFILE, vt); int col = 1;// w w w . j a v a 2 s.c om profile.scale_factor = vt.getDouble(col++); profile.loaderStartTime = vt.getTimestamp(col++); profile.loaderStopTime = vt.getTimestamp(col++); JSONUtil.fromJSONString(profile.users_per_itemCount, vt.getString(col++)); if (LOG.isDebugEnabled()) LOG.debug(String.format("Loaded %s data", AuctionMarkConstants.TABLENAME_CONFIG_PROFILE)); }
From source file:net.freechoice.model.orm.Map_Post.java
@Override public FC_Post mapRow(final ResultSet rs, int rowNum) throws SQLException { FC_Post post = new FC_Post(); post.id = rs.getInt(1);/* ww w . ja v a 2 s . com*/ post.status = rs.getShort(2); post.id_author = rs.getInt(3); post.name_author = rs.getString(4); post.time_posted = rs.getTimestamp(5); post.num_read = rs.getInt(6); post.num_comment = rs.getInt(7); post.title = rs.getString(8); post.content = rs.getString(9); return post; }
From source file:org.cleverbus.core.common.asynch.RepairProcessingMsgServiceDbTest.java
@Test public void testRepairProcessingMessages() { msg.setState(MsgStateEnum.PROCESSING); msg.setStartProcessTimestamp(msg.getMsgTimestamp()); messageDao.insert(msg);//from w w w .ja v a2 s . c o m em.flush(); int msgCount = JdbcTestUtils.countRowsInTable(getJdbcTemplate(), "message"); assertThat(msgCount, is(1)); // call repairing repairMsgService.repairProcessingMessages(); em.flush(); // verify results msgCount = JdbcTestUtils.countRowsInTable(getJdbcTemplate(), "message"); assertThat(msgCount, is(1)); getJdbcTemplate().query("select * from message", new RowMapper<Message>() { @Override public Message mapRow(ResultSet rs, int rowNum) throws SQLException { // verify row values assertThat(rs.getLong("msg_id"), is(1L)); assertThat((int) rs.getShort("failed_count"), is(1)); assertThat(rs.getTimestamp("last_update_timestamp"), notNullValue()); assertThat(MsgStateEnum.valueOf(rs.getString("state")), is(MsgStateEnum.PARTLY_FAILED)); return new Message(); } }); }
From source file:ru.org.linux.user.UserLogDao.java
@Nonnull public List<UserLogItem> getLogItems(@Nonnull User user, boolean includeSelf) { String sql = includeSelf/*from ww w .j a v a 2s. c o m*/ ? "SELECT id, userid, action_userid, action_date, action, info FROM user_log WHERE userid=? ORDER BY id DESC" : "SELECT id, userid, action_userid, action_date, action, info FROM user_log WHERE userid=? AND userid!=action_userid ORDER BY id DESC"; return jdbcTemplate.query(sql, new RowMapper<UserLogItem>() { @Override public UserLogItem mapRow(ResultSet rs, int rowNum) throws SQLException { return new UserLogItem(rs.getInt("id"), rs.getInt("userid"), rs.getInt("action_userid"), new DateTime(rs.getTimestamp("action_date")), UserLogAction.valueOf(rs.getString("action").toUpperCase()), (Map<String, String>) rs.getObject("info")); } }, user.getId()); }
From source file:bookUtilities.PopulateReservedBooksServlet.java
private JSONArray getReservedBooks(String email) { String query;/* ww w . ja v a 2s .com*/ JSONArray jsons = new JSONArray(); try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost;user=sa;password=nopw"); Statement st = con.createStatement(); query = "SELECT Book.*, reservedBooks.ReserveDate " + "FROM [HardCover].[dbo].[Book] Book, [HardCover].[dbo].[RegisteredUser] RegisteredUser, [HardCover].[dbo].[ReservedBook] reservedBooks, [HardCover].[dbo].[Person] P " + "WHERE Book.BookUuid = reservedBooks.BookId AND reservedBooks.RegisteredUserId = RegisteredUser.RegisteredUserId AND P.PersonUuid = RegisteredUser.RegisteredUserId " + " AND P.Email = '" + email + "'"; ResultSet rs = st.executeQuery(query); while (rs.next()) { JSONObject bookToAdd = new JSONObject(); Statement st2 = con.createStatement(); Timestamp timeStamp = rs.getTimestamp("ReserveDate"); String timeString = timeStamp.toString(); String bookId = rs.getString("BookUuid"); query = "SELECT AuthorName " + "FROM [HardCover].[dbo].[Author] " + "WHERE BookId = '" + bookId + "';"; ResultSet rs2 = st2.executeQuery(query); rs2.next(); bookToAdd.put("reserveDate", timeString); bookToAdd.put("author", rs2.getString("AuthorName")); bookToAdd.put("title", rs.getString("Title")); bookToAdd.put("cover", rs.getString("Cover")); bookToAdd.put("dateAdded", rs.getString("DateAdded")); bookToAdd.put("numCopies", rs.getString("NumCopies")); bookToAdd.put("bookId", rs.getString("BookUuid")); jsons.add(bookToAdd); } } catch (Exception e) { System.out.println(e.getMessage()); } return jsons; }
From source file:com.github.dbourdette.glass.log.execution.jdbc.JdbcJobExecutions.java
private Page<JobExecution> getLogs(String sqlBase, SqlParameterSource params, Query query) { String sql = query.applySqlLimit("select * " + sqlBase + " order by startDate desc"); List<JobExecution> executions = jdbcTemplate.query(sql, params, new RowMapper<JobExecution>() { @Override/*w ww . j a va2 s.com*/ public JobExecution mapRow(ResultSet rs, int rowNum) throws SQLException { JobExecution execution = new JobExecution(); execution.setId(rs.getLong("id")); execution.setStartDate(rs.getTimestamp("startDate")); execution.setEndDate(rs.getTimestamp("endDate")); execution.setEnded(rs.getBoolean("ended")); execution.setJobGroup(rs.getString("jobGroup")); execution.setJobName(rs.getString("jobName")); execution.setTriggerGroup(rs.getString("triggerGroup")); execution.setTriggerName(rs.getString("triggerName")); execution.setJobClass(rs.getString("jobClass")); execution.setDataMap(rs.getString("dataMap")); execution.setResult(JobExecutionResult.valueOf(rs.getString("result"))); return execution; } }); String countSql = "select count(*) " + sqlBase; Page<JobExecution> page = Page.fromQuery(query); page.setItems(executions); page.setTotalCount(jdbcTemplate.queryForInt(countSql, params)); return page; }