1 package mircoders.storage;
8 import freemarker.template.*;
15 * <b>This class implements the access to the comment-table for the
21 public class DatabaseComment extends Database implements StorageObject{
23 private static DatabaseComment instance;
25 // the following *has* to be sychronized cause this static method
26 // could get preemted and we could end up with 2 instances of DatabaseFoo..
27 // see the "Singletons with needles and thread" article at JavaWorld -mh
28 public synchronized static DatabaseComment getInstance()
29 throws StorageObjectException {
30 if (instance == null) {
31 instance = new DatabaseComment();
32 instance.myselfDatabase = instance;
37 private DatabaseComment() throws StorageObjectException
40 this.hasTimestamp = false;
41 ////this.cache = new HashMap();
42 this.theTable="comment";
44 this.theEntityClass = Class.forName("mircoders.entity.EntityComment");
46 catch (Exception e) { throw new StorageObjectException(e.toString()); }
49 public SimpleList getPopupData()
50 throws StorageObjectException { return getPopupData("title",true); }
52 public boolean deleteByContentId(String id)
53 throws StorageObjectException {
59 /** @todo comments and topics should be deleted */
60 sql = "delete from "+ theTable + " where to_media="+id;
61 //theLog.printInfo("DELETE "+ sql);
65 stmt = con.createStatement();
66 res = stmt.executeUpdate(sql);
67 } catch (SQLException sqe) {
68 new StorageObjectException(sqe.toString());
71 freeConnection(con,stmt);