Ejemplo n.º 1
0
  public void updateCastle(L1Castle castle) {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = L1DatabaseFactory.getInstance().getConnection();
      pstm =
          con.prepareStatement(
              "UPDATE castle SET name=?, war_time=?, tax_rate=?, public_money=?, public_ready_money=?, show_money=?, war_basetime=?, security=? WHERE castle_id=?");
      pstm.setString(1, castle.getName());
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      String fm = sdf.format(castle.getWarTime().getTime());
      //			String fm = DateFormat.getDateTimeInstance().format( //## A1 원본
      //					castle.getWarTime().getTime()); //#
      pstm.setString(2, fm);
      pstm.setInt(3, castle.getTaxRate());
      pstm.setInt(4, castle.getPublicMoney());
      pstm.setInt(5, castle.getPublicReadyMoney());
      pstm.setInt(6, castle.getShowMoney());
      pstm.setInt(7, castle.getWarBaseTime());
      //			String ft = sdf.format(castle.getTimeBase().getTime());
      //			pstm.setString(8, ft);
      pstm.setInt(8, castle.getCastleSecurity());
      pstm.setInt(9, castle.getId());
      pstm.execute();

      _castles.put(castle.getId(), castle);
    } catch (SQLException e) {
      _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }
Ejemplo n.º 2
0
  private void load() {
    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;
    try {
      con = L1DatabaseFactory.getInstance().getConnection();
      pstm = con.prepareStatement("SELECT * FROM castle");

      rs = pstm.executeQuery();
      L1Castle castle = null;
      while (rs.next()) {
        castle = new L1Castle(rs.getInt(1), rs.getString(2));
        castle.setWarTime(timestampToCalendar((Timestamp) rs.getObject(3)));
        castle.setTaxRate(rs.getInt(4));
        castle.setPublicMoney(rs.getInt(5));
        castle.setPublicReadyMoney(rs.getInt(6));
        castle.setShowMoney(rs.getInt(7));
        castle.setWarBaseTime(rs.getInt(8));
        castle.setCastleSecurity(rs.getInt(9));
        //				castle.setTimeBase(timestampToCalendar((Timestamp) rs
        //						.getObject(9)));

        _castles.put(castle.getId(), castle);
      }
    } catch (SQLException e) {
      _log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }