Learn how to a build a cloud-first strategyRegister Now


detect no return record (Simple quetion. but need help)

Posted on 2005-05-10
Medium Priority
Last Modified: 2010-03-31
Very simple question as I have forgotten to bring my java book.
My question is how to i detect no record return from the query.
See my code below

       String IsReqNoExistSQL = "SELECT 'Y' FROM system_conf    " +
                                " WHERE req_no = " + "'" + reqNo + "'" ;
       System.out.println("IsReqNoExistSQL:" + IsReqNoExistSQL);                        
       Statement SessionStatement = dbConn.createStatement();
       ResultSet SessionRS = SessionStatement.executeQuery(IsReqNoExistSQL);
       SessionRS.next();                                   <======= cause error if no record return from the query
       recordExist = SessionRS.getString(1);
Question by:LeanMoreTryMore
1 Comment
LVL 92

Accepted Solution

objects earned 400 total points
ID: 13974189
if (SessionRS.next())
       recordExist = SessionRS.getString(1);

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month20 days, 22 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question