1 5 6 package com.raptus.owxv3.modules.base; 7 8 import com.raptus.owxv3.*; 9 import java.sql.*; 10 14 public class BaseEntryCounter 15 { 16 public static int countActiveEntriesIn(String 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 } 50 51 } | Popular Tags |