Source code: mill/forum/SimpleForumMessage.java
1 package mill.forum;
2
3 import java.sql.SQLException;
4 import java.sql.PreparedStatement;
5 import java.sql.ResultSet;
6
7 import java.util.Calendar;
8
9 import mill.db.DBconnect;
10 import mill.tools.RsetTools;
11
12 public class SimpleForumMessage extends ForumMessage
13 {
14 private static SimpleForumMessage dummy = new SimpleForumMessage();
15 public int maxCountItems(){ return 100; };
16 public long maxTimePeriod(){ return 1000000; };
17 public String getNameClass(){ return "mill.forum.SimpleForumMessage"; };
18
19 public static int classIndex = -1;
20
21 public int getCacheIndex()
22 {
23 if (classIndex == -1)
24 classIndex = getClassIndex();
25
26 //System.out.println("SimpleForumMessage index: "+classIndex);
27 return classIndex;
28 }
29
30 protected SimpleForumMessage(){}
31
32 public static SimpleForumMessage getInstance(DBconnect db__, long id__)
33 throws Exception
34 {
35 return (SimpleForumMessage) dummy.getInstanceNew( db__, id__);
36 }
37
38
39 public SimpleForumMessage(DBconnect db__, Long id_)
40 throws Exception
41 {
42 PreparedStatement st = null;
43 ResultSet rs = null;
44
45 String sql_ =
46 "select a.* "+
47 "from " + (new SimpleForum()).getNameTable() + " a " +
48 "where a.id = ? ";
49
50 /*
51 "select a.* "+
52 "from " + (new SimpleForum()).getNameTable() + " a, " +
53 (new SimpleForum()).getNameTable() + " b " +
54 "where b.id = ? and a.id_thread = b.id_thread "+
55 "order by a.date_post asc";
56 */
57
58 //System.out.println("SQL: "+sql_);
59
60 try
61 {
62 st = db__.conn.prepareStatement( sql_ );
63 st.setLong(1, id_.longValue() );
64 rs = st.executeQuery();
65
66 //System.out.println("ID #1.002: "+id_);
67
68 if (rs.next())
69 {
70 header = RsetTools.getRsetString(rs, "header");
71 text = RsetTools.getRsetString(rs, "text");
72 fio = RsetTools.getRsetString(rs, "fio");
73 email = RsetTools.getRsetString(rs, "email");
74 ip = RsetTools.getRsetString(rs, "ip");
75
76 id = RsetTools.getRsetLong(rs, "id");
77 id_main = RsetTools.getRsetLong(rs, "id_main");
78 id_forum = RsetTools.getRsetLong(rs, "id_forum");
79 id_thread = RsetTools.getRsetLong(rs, "id_thread");
80
81 datePost = RsetTools.getRsetDate(rs, "date_post");
82 isOk = true;
83 }
84 }
85 catch(SQLException e){}
86 finally
87 {
88 try{
89 if (rs != null)
90 {
91 rs.close();
92 rs = null;
93 }
94 }catch(SQLException e1) {}
95
96 try{
97 if (st != null)
98 {
99 st.close();
100 st = null;
101 }
102 }catch(SQLException e2) {}
103 }
104 }
105 }