Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with return the boolean value
    text
    copied!<p>While working with RESTful webservice in java. i cant able to return boolean value. In this code im checking for duplicate. if duplicate exist it should get out of loop. if not it should further proceed with insertion. In this case my ELSE part is working fine. But IF loop is not working with showing error This is my piece of code.</p> <p><strong>Code</strong></p> <pre><code> public Boolean addCategory(String catname,String parentid)throws Exception { PreparedStatement pst = null; boolean resultdata = false; boolean resultdata1 = false; ResultSet rst=null; Statement st = null; int flag = 0; String sql,sql1 = null; try { con = getConnection(); st = con.createStatement(); sql1="select * from xxx where parent_id='"+parentid+"' and category_description='"+catname+"'"; System.out.println("Checks for Duplicate Catgory"); rst = st.executeQuery(sql1); System.out.println("ResultSet"+rst); if(rst!=null&amp;&amp;rst.next()){ String catname1=(String) rst.getObject("category_description"); System.out.println("Category description : "+catname1); System.out.println("Duplicate value is trying to get inserted"); return resultdata1; } else{ /** Is working fine } </code></pre> <p><strong>Console Error Report</strong></p> <pre><code>Database connection --&gt; Database established Checks for Duplicate Catgory ResultSetcom.mysql.jdbc.JDBC4ResultSet@1c1eceb Category description : Test3 Duplicate value is trying to get inserted Jan 21, 2013 10:23:23 AM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container java.lang.NullPointerException </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload