public long getLastJoinTime(String uid, String activityId) { long lastTime = 0; Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { conn = DBUtil.getConnection(); String sql = "select * from `ssyh_main`.`activity_join` where `uid` = ? and `activity_id`=? order by `create_time` desc;"; ps = conn.prepareStatement(sql); ps.setString(1, uid); ps.setString(2, activityId); rs = ps.executeQuery(); if (rs.next()) { lastTime = StringUtil.timestamp2long(rs.getTimestamp("create_time")); } } catch (SQLException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { DBUtil.close(rs, ps, conn); } return lastTime; }