Пример #1
0
 private void load() {
   try (Connection con = L2DatabaseFactory.getInstance().getConnection();
       PreparedStatement statement = con.prepareStatement(GET_FORUMS)) {
     statement.setInt(1, _sqlDPId);
     statement.setInt(2, _forumId);
     try (ResultSet result = statement.executeQuery()) {
       if (result.next()) {
         _forumName = result.getString("forum_name");
         _forumType = Integer.parseInt(result.getString("forum_type"));
         _ownerID = Integer.parseInt(result.getString("forum_owner_id"));
       }
     }
   } catch (Exception e) {
     _log.warning("data error on Forum " + _forumId + " : " + e);
     e.printStackTrace();
   }
   try (Connection con = L2DatabaseFactory.getInstance().getConnection();
       PreparedStatement statement = con.prepareStatement(GET_TOPICS)) {
     statement.setInt(1, _sqlDPId);
     statement.setInt(2, _forumId);
     try (ResultSet result = statement.executeQuery()) {
       while (result.next()) {
         Topic t =
             new Topic(
                 Topic.ConstructorType.RESTORE,
                 _sqlDPId,
                 Integer.parseInt(result.getString("topic_id")),
                 Integer.parseInt(result.getString("topic_forum_id")),
                 result.getString("topic_name"),
                 Integer.parseInt(result.getString("topic_ownerid")),
                 Integer.parseInt(result.getString("topic_permissions")));
         _topic.put(t.getID(), t);
       }
     }
   } catch (Exception e) {
     _log.warning("data error on Forum " + _forumId + " : " + e);
     e.printStackTrace();
   }
 }
Пример #2
0
 public void insertindb() {
   try (Connection con = L2DatabaseFactory.getInstance().getConnection();
       PreparedStatement statement = con.prepareStatement(INSERT_FORUM)) {
     // TODO: needs to be changed
     statement.setInt(1, _sqlDPId);
     statement.setInt(2, _forumId);
     statement.setString(3, _forumName);
     statement.setInt(4, _forumType);
     statement.setInt(5, _ownerID);
     statement.execute();
   } catch (Exception e) {
     _log.warning("error while saving new Forum to db " + e);
   }
 }