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:com.esri.geoportal.harvester.beans.HistoryManagerBean.java
@Override public History.Event read(UUID id) throws CrudlException { try (Connection connection = dataSource.getConnection(); PreparedStatement st = connection .prepareStatement("SELECT taskid,started,completed,report,id FROM EVENTS WHERE ID = ?");) { st.setString(1, id.toString());/*from w w w . j av a 2 s .c o m*/ ResultSet rs = st.executeQuery(); if (rs.next()) { try (Reader reportReader = rs.getClob(4).getCharacterStream();) { History.Event event = new History.Event(); event.setTaskId(UUID.fromString(rs.getString(1))); event.setStartTimestamp(new Date(rs.getTimestamp(2).getTime())); event.setEndTimestamp(new Date(rs.getTimestamp(3).getTime())); event.setReport(deserialize(reportReader, History.Report.class)); event.setUuid(UUID.fromString(rs.getString(5))); return event; } } } catch (IOException | SQLException ex) { throw new CrudlException("Error reading history event", ex); } return null; }
From source file:net.solarnetwork.node.dao.jdbc.JdbcSettingDao.java
@Override protected Setting getBatchRowEntity(BatchOptions options, ResultSet resultSet, int rowCount) throws SQLException { Setting s = new Setting(); s.setKey(resultSet.getString(1));//from ww w. j a va 2 s. c o m s.setType(resultSet.getString(2)); s.setValue(resultSet.getString(3)); s.setModified(resultSet.getTimestamp(4)); s.setFlags(SettingFlag.setForMask(resultSet.getInt(5))); return s; }
From source file:com.esri.geoportal.harvester.beans.HistoryManagerBean.java
@Override public Collection<Map.Entry<UUID, History.Event>> list() throws CrudlException { HashMap<UUID, History.Event> map = new HashMap<>(); try (Connection connection = dataSource.getConnection(); PreparedStatement st = connection .prepareStatement("SELECT taskid,started,completed,report,id FROM EVENTS");) { ResultSet rs = st.executeQuery(); while (rs.next()) { try (Reader reportReader = rs.getClob(4).getCharacterStream();) { History.Event event = new History.Event(); event.setTaskId(UUID.fromString(rs.getString(1))); event.setStartTimestamp(new Date(rs.getTimestamp(2).getTime())); event.setEndTimestamp(new Date(rs.getTimestamp(3).getTime())); event.setReport(deserialize(reportReader, History.Report.class)); event.setUuid(UUID.fromString(rs.getString(5))); map.put(event.getUuid(), event); }/*www .j av a 2s.c o m*/ } } catch (IOException | SQLException ex) { throw new CrudlException("Error selecting broker definition", ex); } return map.entrySet(); }
From source file:com.ewcms.component.auth.dao.UserDAO.java
@Override public User getUser(String username) { String sql = "Select * From component_auth_user Where username = ?"; List<User> list = jdbcTemplate.query(sql, new Object[] { username }, new RowMapper<User>() { @Override/*from w w w . j a v a2 s .c o m*/ public User mapRow(ResultSet rs, int rowNum) throws SQLException { User user = new User(); user.setUsername(rs.getString("username")); user.setName(rs.getString("name")); user.setEmail(rs.getString("email")); user.setPassword(rs.getString("password")); user.setEnabled(rs.getBoolean("enabled")); user.setRegisterDate(rs.getTimestamp("register_date")); return user; } }); return list.isEmpty() ? null : list.get(0); }
From source file:com.esri.geoportal.harvester.beans.HistoryManagerBean.java
@Override public History buildHistory(UUID taskid) throws CrudlException { History history = new History(); try (Connection connection = dataSource.getConnection(); PreparedStatement st = connection.prepareStatement( "SELECT taskid,started,completed,report,id FROM EVENTS WHERE taskid = ?");) { st.setString(1, taskid.toString()); ResultSet rs = st.executeQuery(); while (rs.next()) { try (Reader reportReader = rs.getClob(4).getCharacterStream();) { History.Event event = new History.Event(); event.setTaskId(UUID.fromString(rs.getString(1))); event.setStartTimestamp(new Date(rs.getTimestamp(2).getTime())); event.setEndTimestamp(new Date(rs.getTimestamp(3).getTime())); event.setReport(deserialize(reportReader, History.Report.class)); event.setUuid(UUID.fromString(rs.getString(5))); history.add(event);/*w ww . j ava2 s. c om*/ } } return history; } catch (IOException | SQLException ex) { throw new CrudlException("Error selecting broker definition", ex); } }
From source file:com.mvdb.etl.dao.impl.JdbcOrderDAO.java
@Override public void findAll(Timestamp modifiedAfter, final Consumer consumer) { String sql = "SELECT * FROM ORDERS where orders.update_time >= ?"; getJdbcTemplate().query(sql, new Object[] { modifiedAfter }, new RowCallbackHandler() { @Override/* www .j a v a 2 s . co m*/ public void processRow(ResultSet row) throws SQLException { Order order = new Order(); order.setOrderId(row.getLong("order_id")); order.setNote(row.getString("note")); order.setSaleCode(row.getInt("sale_code")); Date createTime = new java.util.Date(row.getTimestamp("create_time").getTime()); order.setCreateTime(createTime); Date updateTime = new java.util.Date(row.getTimestamp("update_time").getTime()); order.setUpdateTime(updateTime); consumer.consume(order); } }); }
From source file:com.p000ison.dev.simpleclans2.converter.Converter.java
public void convertKills() throws SQLException { ResultSet result = from.query("SELECT * FROM `sc_kills`;"); while (result.next()) { Timestamp date;/* w w w .j a v a 2s.co m*/ try { date = result.getTimestamp("date"); } catch (Exception e) { date = new Timestamp(System.currentTimeMillis()); } insertKill(result.getString("attacker"), result.getString("attacker_tag"), result.getString("victim"), result.getString("victim_tag"), result.getString("kill_type"), result.getBoolean("war"), date); } }
From source file:de.anycook.db.mysql.DBGetRecipe.java
public Date getLastModified() throws SQLException { PreparedStatement preparedStatement = connection .prepareStatement("SELECT last_change FROM gerichte ORDER BY last_change DESC LIMIT 1"); ResultSet resultSet = preparedStatement.executeQuery(); if (resultSet.next()) { return resultSet.getTimestamp("last_change"); }//from ww w. jav a 2 s . c o m return new Date(); }
From source file:net.riezebos.thoth.content.comments.dao.CommentDao.java
protected Comment setComment(ResultSet rs) throws SQLException { Comment comment = new Comment(); int idx = 1;/* w ww .ja v a 2 s .c om*/ comment.setId(rs.getLong(idx++)); comment.setUserName(rs.getString(idx++)); comment.setContextName(rs.getString(idx++)); comment.setDocumentPath(rs.getString(idx++)); comment.setTimeCreated(rs.getTimestamp(idx++)); comment.setTitle(rs.getString(idx++)); comment.setDao(this); return comment; }