Ejemplo n.º 1
0
 public void init() throws ServletException {
   jIRCdMBean jircd = (jIRCdMBean) getServletContext().getAttribute("jircd");
   try {
     Class.forName(jircd.getProperty("chanserv.jdbc.driver"));
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
   Network network = (Network) getServletContext().getAttribute("jircd.irc.network");
   try {
     Connection conn = DriverManager.getConnection(jircd.getProperty("chanserv.jdbc.url"));
     try {
       PreparedStatement stmt =
           conn.prepareStatement(jircd.getProperty("chanserv.sql.queryChannels"));
       try {
         ResultSet rs = stmt.executeQuery();
         while (rs.next()) {
           Channel channel = new RegisterableChannel(rs, network, jircd);
         }
         rs.close();
       } finally {
         stmt.close();
       }
     } finally {
       conn.close();
     }
   } catch (SQLException sqle) {
     throw new ServletException(sqle);
   }
 }
Ejemplo n.º 2
0
 public void destroy() {
   jIRCdMBean jircd = (jIRCdMBean) getServletContext().getAttribute("jircd");
   String shutdownURL = jircd.getProperty("chanserv.jdbc.url.shutdown");
   if (shutdownURL != null) {
     try {
       Connection conn = DriverManager.getConnection(shutdownURL);
       try {
         String shutdownSQL = jircd.getProperty("chanserv.sql.shutdown");
         if (shutdownSQL != null) {
           Statement stmt = conn.createStatement();
           try {
             stmt.executeUpdate(shutdownSQL);
           } finally {
             stmt.close();
           }
         }
       } finally {
         conn.close();
       }
     } catch (SQLException sqle) {
       // ignore
     }
   }
 }