Changeset 353 for kraken-cron/src

Show
Ignore:
Timestamp:
10/17/09 16:31:47 (11 months ago)
Author:
periphery
Message:

minor modification made on kraken-cron.
Statement is changed to PreparedStatement to prevent SQL injection.

Location:
kraken-cron/src/main/java/org/krakenapps/cron
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • kraken-cron/src/main/java/org/krakenapps/cron/CronScript.java

    r352 r353  
    9090                } catch (NumberFormatException e) { 
    9191                        context.println("USAGE : SCHEDULE_ID"); 
    92                 } catch (NoSuchElementException e){ 
     92                } catch (NoSuchElementException e) { 
    9393                        context.println("cron script: no schedule of given id %d", Integer.parseInt(args[0])); 
    9494                } 
     
    162162        } 
    163163 
     164 
    164165} 
  • kraken-cron/src/main/java/org/krakenapps/cron/CronService.java

    r352 r353  
    1010 */ 
    1111public interface CronService { 
    12         void registerSchedule(Schedule schedule); 
     12 
     13        int registerSchedule(Schedule schedule); 
    1314 
    1415        void unregisterSchedule(int i); 
  • kraken-cron/src/main/java/org/krakenapps/cron/impl/CronConfig.java

    r352 r353  
    116116        private int update(String expression) { 
    117117                Statement st = null; 
     118                PreparedStatement pst = null; 
    118119                int autoIncKeyFromApi = -1; 
    119120                try { 
    120121                        connect(); 
     122                        pst = connection.prepareStatement(expression); 
     123                        pst.execute(); 
    121124                        st = connection.createStatement(); 
    122                         st.executeUpdate(expression); 
    123125                    ResultSet rs = st.executeQuery("CALL IDENTITY()"); 
    124126                    if (rs.next()) { 
     
    130132                } catch (Exception e) { 
    131133                        logger.debug("CronConfig : exception raised during " + expression + ". IGNORED."); 
     134                        e.printStackTrace(); 
    132135                        rollback(); 
    133136                } finally { 
  • kraken-cron/src/main/java/org/krakenapps/cron/impl/CronServiceImpl.java

    r352 r353  
    4242         */ 
    4343        @Override 
    44         public void registerSchedule(Schedule schedule) { 
     44        public int registerSchedule(Schedule schedule) { 
    4545                int id = config.addEntry(schedule); 
    4646                this.map.put(id, schedule); 
    4747                scheduler.put(id, schedule); 
     48                return id; 
    4849        } 
    4950