Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: mill/forum/ForumConfig.java


1   package mill.forum;
2   
3   import java.sql.SQLException;
4   import java.sql.ResultSet;
5   import java.sql.PreparedStatement;
6   
7   import mill.db.DBconnect;
8   import mill.tools.RsetTools;
9   import mill.main.CacheItem;
10  
11  public class ForumConfig extends CacheItem
12  {
13      private static ForumConfig dummy = new ForumConfig();
14      public int maxCountItems(){ return 1; };
15      public long maxTimePeriod(){ return 1000000; };
16      public String getNameClass(){ return "mill.forum.ForumConfig"; };
17  
18      public static int classIndex = -1;
19  
20      public int getCacheIndex()
21      {
22    if (classIndex == -1)
23      classIndex = getClassIndex();
24  
25  //System.out.println("ForumConfig index: "+classIndex);
26    return classIndex;
27      }
28  
29      protected ForumConfig(){ super(); };
30  
31      public static ForumConfig getInstance(DBconnect db_, Long id)
32    throws Exception
33      {
34        return getInstance( db_, id.longValue());
35      }
36  
37      public static ForumConfig getInstance(DBconnect db_, long id)
38    throws Exception
39      {
40        return (ForumConfig) dummy.getInstanceNew( db_, id);
41      }
42  
43      public long id_forum = -1;
44      public boolean isAllThread = false;
45      public boolean isUseLocale = false;
46      public String nameForum = "";
47      public boolean isUseProperties = false;
48  
49  
50  /*
51  @-deprecated
52     public ForumConfig(DBconnect db_, long id_forum)
53     {
54    this(db_, new Long(id_forum) );
55     }
56  */
57  
58     public ForumConfig(DBconnect db_, Long id_forum_)
59     {
60    PreparedStatement ps = null;
61          ResultSet rs = null;
62    try
63    {
64        String sql_ = "select * from main_forum where id_forum = ? ";
65  
66        ps = db_.conn.prepareStatement( sql_ );
67        ps.setLong(1, id_forum_.longValue() );
68        rs = ps.executeQuery();
69  
70        if (rs.next())
71        {
72      id_forum = id_forum_.longValue();
73      isAllThread = (RsetTools.getRsetInt(rs, "is_all_thread", 0)==0?false:true);
74      isUseLocale = (RsetTools.getRsetInt(rs, "is_use_locale", 0)==0?false:true);
75      nameForum   = RsetTools.getRsetString(rs, "name_forum", "");
76      isUseProperties = (RsetTools.getRsetInt(rs, "is_use_properties", 0)==0?false:true);
77        }
78    }
79    catch(Exception e) {}
80    finally
81    {
82      try{
83        if (rs != null)
84        {
85          rs.close();
86          rs = null;
87        }
88      }catch(SQLException e1) {}
89  
90      try{
91        if (ps != null)
92        {
93          ps.close();
94          ps = null;
95        }
96      }catch(SQLException e2) {}
97    }
98     }
99  
100 }