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:lydichris.smashbracket.persistence.TournamentMapper.java
@Override public Tournament mapRow(ResultSet rs, int rowNum) throws SQLException { Tournament tournament = new Tournament(rs.getString("uuid"), rs.getString("name"), rs.getTimestamp("start_time"), rs.getInt("size_limit"), rs.getString("location"), rs.getString("game"), rs.getString("host"), TournamentType.fromString(rs.getString("format")), rs.getString("description"), rs.getInt("is_bracket_visible") == 1); return tournament; }
From source file:hoot.services.controllers.osm.OSMResourceTestAbstract.java
protected Timestamp getCurrentDBTime() throws Exception { try (Connection conn = dbcpDatasource.getConnection()) { String sql = "SELECT now()"; try (PreparedStatement stmt = conn.prepareStatement(sql)) { ResultSet rs = stmt.executeQuery(); rs.next();//from w ww .j a va2s .c o m return rs.getTimestamp(1); } } }
From source file:org.jasig.schedassist.impl.reminder.PersistedReminderImplRowMapper.java
@Override public PersistedReminderImpl mapRow(ResultSet rs, int rowNum) throws SQLException { PersistedReminderImpl result = new PersistedReminderImpl(); result.setBlockEndTime(rs.getTimestamp("event_end")); result.setBlockStartTime(rs.getTimestamp("event_start")); result.setOwnerId(rs.getLong("owner_id")); result.setRecipientId(rs.getString("recipient")); result.setReminderId(rs.getLong("reminder_id")); result.setSendTime(rs.getTimestamp("send_time")); return result; }
From source file:com.wabacus.system.datatype.TimestampType.java
public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException { java.sql.Timestamp ts = rs.getTimestamp(iindex); if (ts == null) return null; return new Date(ts.getTime()); }
From source file:com.wabacus.system.datatype.TimestampType.java
public Object getColumnValue(ResultSet rs, String column, AbsDatabaseType dbtype) throws SQLException { java.sql.Timestamp ts = rs.getTimestamp(column); if (ts == null) return null; return new Date(ts.getTime()); }
From source file:com.wabacus.system.datatype.CTimestampType.java
public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException { java.sql.Timestamp cts = rs.getTimestamp(iindex); if (cts == null) return null; Calendar cd = Calendar.getInstance(); cd.setTimeInMillis(cts.getTime());// w w w . j a v a 2s. com return cd; }
From source file:com.wabacus.system.datatype.CTimestampType.java
public Object getColumnValue(ResultSet rs, String column, AbsDatabaseType dbtype) throws SQLException { java.sql.Timestamp cts = rs.getTimestamp(column); if (cts == null) return null; Calendar cd = Calendar.getInstance(); cd.setTimeInMillis(cts.getTime());//from ww w .j a va2s. c o m return cd; }
From source file:net.jmhertlein.mcanalytics.plugin.daemon.request.UniqueLoginsPerDayRequestHandler.java
@Override public JSONObject handle(Connection conn, StatementProvider stmts, JSONObject request, ClientMonitor client) throws Exception { PreparedStatement stmt = conn.prepareStatement(stmts.get(SQLString.GET_UNIQUE_LOGINS)); stmt.clearParameters();/*from ww w . ja va 2 s. co m*/ stmt.setTimestamp(1, Timestamp.valueOf(LocalDate.parse(request.getString("start")).atStartOfDay())); stmt.setTimestamp(2, Timestamp.valueOf(LocalDate.parse(request.getString("end")).plusDays(1).atStartOfDay())); ResultSet res = stmt.executeQuery(); Map<String, Integer> counts = new HashMap<>(); while (res.next()) { counts.put(res.getTimestamp("login_day").toLocalDateTime().toLocalDate().toString(), res.getInt("login_count")); } JSONObject ret = new JSONObject(); ret.put("logins", counts); res.close(); stmt.close(); return ret; }
From source file:net.jmhertlein.mcanalytics.plugin.daemon.request.FirstJoinRequestHandler.java
@Override public JSONObject handle(Connection conn, StatementProvider stmts, JSONObject request, ClientMonitor client) throws Exception { //System.out.println("Handler: starting..."); PreparedStatement stmt = conn.prepareStatement(stmts.get(SQLString.GET_NEW_PLAYER_LOGINS_HOURLY)); stmt.clearParameters();//from ww w .j a v a 2 s.c o m stmt.setTimestamp(1, Timestamp.valueOf(LocalDate.parse(request.getString("start")).atStartOfDay())); stmt.setTimestamp(2, Timestamp.valueOf(LocalDate.parse(request.getString("end")).plusDays(1).atStartOfDay())); ResultSet res = stmt.executeQuery(); Map<String, Integer> counts = new HashMap<>(); while (res.next()) { counts.put(res.getTimestamp("hour_joined").toLocalDateTime().toString(), res.getInt("login_count")); } JSONObject ret = new JSONObject(); ret.put("first_login_counts", counts); res.close(); stmt.close(); //System.out.println("Handler: done, returning."); return ret; }
From source file:net.jmhertlein.mcanalytics.plugin.daemon.request.PastOnlinePlayerCountRequestHandler.java
@Override public JSONObject handle(Connection conn, StatementProvider stmts, JSONObject req, ClientMonitor c) throws SQLException { //System.out.println("Handler: starting..."); PreparedStatement stmt = conn.prepareStatement(stmts.get(SQLString.GET_HOURLY_PLAYER_COUNTS)); stmt.clearParameters();/*www . ja v a2 s . com*/ stmt.setTimestamp(1, Timestamp.valueOf(LocalDateTime.parse(req.getString("start")))); stmt.setTimestamp(2, Timestamp.valueOf(LocalDateTime.parse(req.getString("end")))); ResultSet res = stmt.executeQuery(); Map<String, Integer> counts = new HashMap<>(); while (res.next()) { counts.put(res.getTimestamp("instant").toLocalDateTime().toString(), res.getInt("count")); } JSONObject ret = new JSONObject(); ret.put("counts", counts); res.close(); stmt.close(); conn.close(); //System.out.println("Handler: done, returning."); return ret; }