I have one query that returns string value, my query is
select case when (select count (distinct style_packing_spec_id) from packing_spec_uses_pack p,style_pack sp where sp.style_pack_id=p.style_pack_id and sp.style_id=1701) != (select count (distinct style_packing_spec_id) from style_packing_spec where style_id=1701) then ‘DonotProceed’ else ‘Proceed’ end “;
It gives result as below
?case?
----------
DonotProceed
how to execute this is in java, how to handle this result set,I tried like this
String sql="query";
ResultSet rs=stmt.executeQuery(sql);
It returns nullpointerexception
String str=rs.getString(1);
I’ve never had boolean returned from a query (Oracle doesn’t do that…), but I assume that it works. You just need to go to the first row of the result set, and the column index starts with 1 (not 0).
Update:
Are you using Java 1.4 ? For Java5 and above, this should be taken care of by auto-boxing. But you can also fix it by using a primitive boolean variable to match what JDBC returns: