• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How to find null (ResultSet + PreparedStatement))

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
following method i am calling recursively. craeting a dyanamic menu on basis of userid and application code so i am finding the childs of child and so on ......... Connection object is global here. Rest all the thing are local.


Problem is program flow is not going into if(matrixResultSet==null)

can anybody help me out.

i tried sql query on sql promt it showing null. what could be the problem







ResultSet matrixResultSet=null;
PreparedStatement matrixPreparedStatement=null;

if(userId != null && appCode != null && userId.trim().length() > 0 && appCode.trim().length() > 0){
matrixPreparedStatement = (PreparedStatement)con.prepareStatement( " Select * from ICE_MODULE_MENU where APP_CODE=? AND MOD_PARENT_MENU=?");
}

matrixPreparedStatement.setString(1, appCode);
matrixPreparedStatement.setString(2, moduleCode);
matrixPreparedStatement.executeQuery();
matrixResultSet = matrixPreparedStatement.getResultSet();

if(matrixResultSet==null){

//Flow is not coming here

menuString.append(",");

}


while (matrixResultSet.next()){
String parentModuleName = matrixResultSet.getString("MOD_CODE");

logger.debug("this.renderURL"+this.renderURL);

menuString.append("[null,'Home','"+this.renderURL+"/index.jsp',null,null,");

logger.debug(parentModuleName);
this.makeMenu(parentModuleName, appCode, userId, con);

menuString.append("] ");

}
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ResultSet will never be null. It may be empty, but never null.
 
Tushar Kherde
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul,

but my problem is how to find that the resultset is empty.
is there any method
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first call to matrixResultSet.next() would return false.

Code something like this..
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic