3676

ResultSet is not null still resultset.next() returning false

Question:

I'm trying to access a procedure which returns a cursor, my resultset is not null still resultset.next() is returning false and that's why control is not entering into while, please see below mention my procedure and my java code and help me on this.

this is my procedure:

PROCEDURE get_app_biz_summary (p_application_name_i IN VARCHAR2, p_summary_o OUT SYS_REFCURSOR) IS BEGIN IF p_application_name_i = 'ALL' THEN OPEN p_summary_o FOR SELECT application_name, creation_date, SUM (success_count) success, SUM (error_count) "error", SUM (warning_count) warning FROM xxcss_sfm_app_biz_summary WHERE 1 = 1 AND creation_date >= SYSDATE - 4 GROUP BY application_name, creation_date; ELSE OPEN p_summary_o FOR SELECT application_name, biz_process_name, creation_date, SUM (success_count) success, SUM (error_count) "error", SUM (warning_count) warning FROM xxcss_sfm_app_biz_summary WHERE application_name = NVL (p_application_name_i, application_name) AND creation_date >= SYSDATE - 4 GROUP BY application_name, biz_process_name, creation_date; END IF; END get_app_biz_summary; END XXCSS_ORDER_STATUS_PKG;

/ and this is my java code:

try { OracleCallableStatement cs = (OracleCallableStatement)jdbcTemplate // CallableStatement cs=jdbcTemplate .getDataSource() .getConnection() .prepareCall( "{call APPS.XXCSS_ORDER_STATUS_PKG.GET_APP_BIZ_SUMMARY(?,?)}"); cs.setString(1, appName); cs.registerOutParameter(2, OracleTypes.CURSOR); cs.execute(); resultSet= (OracleResultSet)cs.getCursor(2); if(resultSet==null ) System.out.println("resultset null...."); // resultset is not null System.out.println(resultSet.next()); // its returning false while(resultSet.next()){ System.out.println("in while"); IBSave ibSave=new IBSave(); ibSave.setApplicationName(resultSet.getString("APPLICATION_NAME"));

Answer1:

Dont call resultSet.next() unnecessarily because as per documentation :- <a href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/sql/ResultSet.java#ResultSet.next%28%29" rel="nofollow">http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/sql/ResultSet.java#ResultSet.next%28%29</a>. If you call

System.out.println(resultSet.next()); // its returning false

it will move cursor to next row. and again calling

while(resultSet.next()){

is actually pointed to your second row. So you have only one record returned in resultset.

Answer2:

1.Can you make sure your database is returning data

2.Can you check with resultSet= (OracleResultSet)cs.getCursor(2); Maybe remove this particular line??

Hope this helps!!

Recommend

  • ResultSet is not null still resultset.next() returning false
  • Returned ref cursor not supported
  • Oracle Enterprise Manager job is Hung
  • Oracle - Change start day of Week - Tuesday
  • ORA-01775: looping chain of synonyms but there are no synonyms
  • Designing Simple Schema for Disaggregation of Demand Forecast
  • oracle plsql if not found repeat
  • Oracle Query - Selecting records using column data from first table
  • Oracle - PLS-00103: Encountered the symbol “END” when try to create JOB
  • ORA-22806: not an object or REF : error while generating XML output
  • Type date default sysdate in Mysql
  • Failed to create creation time in APEX report
  • In oracle SQL, how would you obtain the timestamp representing the start of the week?
  • How can I get the Current Date in a Cognos query expression?
  • Want to get previous date from current date
  • Adding links to an array with jquery
  • (oracle) insert in stored procedure very slow compared to insert run manually
  • Bash script hangs
  • Getting ORA-01861 - Literal does not match format string on SQLPlus Only
  • Admob Interstitial Ad showing black with new Ad unit ID
  • How do I create shared library using ld?
  • opencv display image without x server
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • C: Incompatible pointer type initializing
  • Linq Objects Group By & Sum
  • Read text file and split every line in MSBuild
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • embed rChart in Markdown
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?