java - Preventing Prepared Statement Leaks using Checkstyles -


lets have following code :

preparedstatement ps = null; resultset rs = null; try {   ps = conn.createstatement(myquerystring);   rs = ps.executequery();   // process results... } catch (java.sql.sqlexception e) {   log.error("an error!", e);   throw new exception("i'm sorry. query did not work."); } {   ps.close();   // if forgot leak   rs.close();   // if forgot leak } 

and wished catch scenario forget close preparedstatement or resultset using checkstyles. possible, , if so, how go it?

pmd , findbugs both have warnings preparedstatements (and resultsets , connections). i'd suggest using them type of warning, since checkstyle has more code style finding data-flow bugs such this.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -