| Author |
How to find null (ResultSet + PreparedStatement))
|
Tushar Kherde
Ranch Hand
Joined: Apr 28, 2006
Posts: 56
|
|
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("] "); }
|
Tushar
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
The ResultSet will never be null. It may be empty, but never null.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Tushar Kherde
Ranch Hand
Joined: Apr 28, 2006
Posts: 56
|
|
Thanks Paul, but my problem is how to find that the resultset is empty. is there any method
|
 |
Dag Corell
Greenhorn
Joined: Sep 19, 2006
Posts: 3
|
|
The first call to matrixResultSet.next() would return false. Code something like this..
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: How to find null (ResultSet + PreparedStatement))
|
|
|