aspose file tools
The moose likes JDBC and Relational Databases and the fly likes How to find null (ResultSet + PreparedStatement)) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How to find null (ResultSet + PreparedStatement))" Watch "How to find null (ResultSet + PreparedStatement))" New topic

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);
matrixResultSet = matrixPreparedStatement.getResultSet();


//Flow is not coming here



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



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

menuString.append("] ");


Paul Sturrock

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

Joined: Sep 19, 2006
Posts: 3
The first call to would return false.

Code something like this..
I agree. Here's the link:
subject: How to find null (ResultSet + PreparedStatement))