KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > modules > base > BaseEntryCounter


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.modules.base;
7
8 import com.raptus.owxv3.*;
9 import java.sql.*;
10 /**
11  * This class is used to fing the count of avtive entries from a vmodule
12  *
13  */

14 public class BaseEntryCounter
15 {
16     public static int countActiveEntriesIn(String JavaDoc vmoduleid)
17     {
18         int count=0;
19         Connection conn=null;
20         VModuleManager vmm=VModuleManager.getInstance();
21         VModule vmodule=vmm.getVModule(vmoduleid);
22         NwslistManager nwsList = new NwslistManager(vmodule.getIdentification());
23         nwsList.setDataSource(vmodule.getDatasource());
24         try
25         {
26             
27             conn=nwsList.openConnection();
28             PreparedStatement ps=conn.prepareStatement("select count(*) from "+nwsList.getTableID()+" where flagvisible=?");
29             ps.setBoolean(1,true);
30             ResultSet rs=ps.executeQuery();
31             if(rs.next())
32             {
33                 count=rs.getInt(1);
34             }
35             rs.close();
36             ps.close();
37             nwsList.closeConnection(conn);
38         }catch(SQLException e)
39         {
40             LoggingManager.log("Error while retriving count of entries in vmodule:"+vmoduleid," the error is:"+e);
41             if(conn!=null)
42             {
43                 try{nwsList.closeConnection(conn);}catch(SQLException se){}
44             }
45         }
46
47         return count;
48     }//end countActiveEntriesIn
49

50     
51 }//end class
52
Popular Tags