How can we check whether a ResultSet is EMPTY or NOT ?

i'm getting some data inside ResulSet (using JDBC inside Servlet).
now i want to redirect response according to ResultSet...., if ResultSet is EMPTY then on diff page, else on different page...
how can i check whether a ResultSet is empty or not...
i've used next() , wasNull() methods ,,, but not solving the purpose...
thanx in advance...

What you could do is to ask the database fora
record count and check that for zero.
How?????You just do an SQL statement but instead of the list of fields after SELECT you put
SELECT count(*) FROM ...... WHERE .....
That returns a single integer value into the resultset giving the number of matching records currently in the database.
The trouble is you can't be certain that when you subsequently access the records the number won't have changed, because databases are generally accessible to more than one process at a time and some other process might add or delete a record between counting and retrieving or, for that matter, during the process of retrieval.
Also the count is likely to take more time than just doing rs.next() and seeing if you get a record.
Since you seem to be in a servlet environment you should consider doing the database query and the first rs.next() at the top of the servlet/JSP that presents the results and, if there are no records, using getServletContext.getRequestDispatcher(...).forward(request, response) to swich to your error page if it returns false.
So the stucture looks like:
rs = stmt.executeQuery(......);
if(!rs.next())
      getServletContext().getRequestDispatcher("/noresultspage.jsp").forward(request, response);
else {
     do   {
         .... display result data
      } while(rs.next());
    }

Similar Messages

  • How can i check whether my phone is unlocked or not

    How can i check whether my phone is unlocked or not

    rozhan.m wrote:
    Im in srilanka, my sister brought me this phone from UK. i dont kwon how to call apple from here. pls help me
    Nothing we can do to help you.  If it was bought in the UK from an Apple store as unlocked, it is unlocked.  If it was bought anywhere else, it will be locked, and only the carrier it is locked to will be able to unlock it.
    If you've tried a local SIM and it has not worked, then you have your answer, it is locked.

  • How to check whether the Resultset is empty or not ??

    I wanna check whether my Result set is empty or not ( I don't want the no of rows it contains..) i'm using this function...
    boolean result=myResultSet.isAfterLast() | myResultSet.isBeforeFirst() ;
    if (result == true)
    {//Result Set is populated
    else
    {//ResultSet Blank
    Is it ok to do like this ?? Or is there any other functanality to do this, since in big appl..i'm using it more than 10-15 times & it's working fine evrywhere except for one jsp where it is returing TRUE everytime ...
    Help Appreciated !!

    try,
    rs = pstmt.executeQuery();
    boolean b = false;
    if( b = rs.next() ) {
    while( b ) {
    //... rs.getXXX( YYY );
    b = rs.next();
    else {
    //...empty rs processing
    or,
    ResultSet rs = ps.executeQuery();
    if(rs.next()) {
    do {
    System.out.println(rs.getString(1));
    } while(rs.next());
    } else {
    System.out.println('empty result set');
    but I usually avoid using do...while although this may be an exception.

  • In Generic Extraction how can we know whether it is Delta Enabled or not?

    In Generic Extraction how can we know whether it is Delta Enabled or not?
    Thanks,
    Pramod.

    Hi Pramod,
    In R/3 use RSO2 tcode and enter your DS name and click "Change / Display" In this "Press F7 or Display Filed List" icon near to Generic Delta.In this Screen if Delta Update is Checked means it supports delta method  otherwise it won't support delta method.
    Note:Assign Points if it helps.
    -Arun.M.D

  • How can I check that second hand macbook air is not stolen?

    How can I check that second hand macbook air is not stolen?

    Ask for the original purchase receipts.
    Take it to the Apple store  and make sure that the computer is not stolen
    provided they have any such information.
    Best.

  • HT201328 how can I know whether my IME is blocked or not?

    How can I know whether my IME is blocked or not?

    Ask your wireless carrier.
    Where did you acquire this iPhone? Common scam
    is to sell iPhone in working condition so buyer can see
    it works, then seller reports iPhone as stolen/lost for
    insurance claim. Insurance company works with
    cellular provider to blacklist the iPhone and suddenly
    it no longer works.
    Or is your iPhone still locked to a wireless carrier as
    you imply in https://discussions.apple.com/thread/5001327?tstart=0

  • HOW can i check my iphone4s is factory unlock  or not ?

    HOW can i check my iphone4s is factory unlock  or not  i wants to update my software version at present its version is 6.0.1(10A523) can any one tell me?

    Do you have iTunes 11.0.1 on computer?
    iOS: Device not recognized in iTunes for Windows
    iPhone not appearing in iTunes

  • How can I evaluate if a collection is empty or not with struts logic tag?

    How can I evaluate if a collection is empty or not with struts logic tag?
    I tried with logic empty tag. but the tag evaluated if a collection is null or not.
    I would like to do like this below.
    List list = new ArrayList();
    set(list);
    <logic:XXXX name="someForm" property="list">
    The list size is 0.
    </logic>thanks in advance.

    U can use :
    <logic:present name="urform" property="urlist">
    </logic:present>
    to check "urlist" is empty or not

  • How can I check whether DIAdem a 32 or 64 bit version?

    Hi all,
    How can I check in a script whether DIAdem a 32 or 64 bit version? Is there any variable or function?
    I need this tcheck to avoid loading 32-Bit COM objects.
    Thanks
    gemu

    Hi gemu,
    The variable you are looking for is APPLICATIONBITNESS. The variable is available in DIAdem 2014 but without documentation. This documentation will be available in DIAdem 2015. The variable is read only and returns a integer (32 or 64)
    Hope that helps
    Winfried

  • How can I check whether I have uploaded all my photos?

    I have uploaded my photos in several sessions. How can I ensure easily that all photos including those in sub-directories of my main photo folder have been uploaded? i use revel on the Mac.
    iandunbar

    One easy way: reset after importing (which can be done from library module - e.g. main menu, context menu, quick-develop...). If you can't even get that far, consider using exiftool to strip the xmp from DNGs and/or jpegs, or just delete xmp sidecar file in case of proprietary raw.

  • How can I check whether or not an database table exists?

    Hi,
    I am new to ABAP programming. And now I want to write an function that check whether an table exists in the dictionary.
    It request the table name was given by the user input. So I have to check it dynamically.
    Please give me some guide if you know about that.
    Thanks.

    Hi,
    All the table names exist in DD02l table.
    Fetch data from DD02l table by passing selectin screen parameter .
    REPORT ysdn_new .
    PARAMETERS: p_tab LIKE dd02l-tabname.
    DATA: v_tab LIKE p_tab.
    SELECT SINGLE tabname INTO v_tab FROM dd02l WHERE tabname = p_tab.
    WRITE v_tab.
    If ypu want to fetch from TADIR table only means you have to pass selection screen parameter in place of obj_name and TABL for OBJECT field.
    SELECT SINGLE tabname INTO v_tab
    FROM TADIR
    WHERE obj_name = p_tab
       AND    object = 'TABL'.
    This is other way of getting table name by passing selection screen parameter
    this will work.
    Please reward points if helpful...
    Regds
    Sivaparvathi

  • How can I check whether new versions of Firefox are compatible with my add-ons? I specifically need to know this regarding Zotero as I would very much hate to loose my reference data base when changing from one version of Firefox to the next ...

    Is there an add-on that can help me with this? Or do I just install the new version and hope for the best?

    Firefox 9.0.1 is a real old version and is no longer supported - Firefox 24.0 is the current release version.
    Open the Add-0ns manager tab and click on '''More''' for each extension that you have installed. Near the bottom of each "More" there should be a link that will take you to the download page where you can verify compatibility.
    Or use this extension - https://addons.mozilla.org/en-US/firefox/addon/is-it-compatible/ - but I'm not sure how well it will work when you are so many versions 'behind the curve'.

  • Help! How can I check whether the developer tools are installed on my iMac?

    Hi, I'm new to macs and would like some help with finding out whether or not the Developer Tools are installed on my iMac.I don't remember having any sort of installation CD/DVD.
    Thanks

    Welcome  
    http://developer.apple.com/search/index.php?q=xcode
    Apple Developer Technologies Overview - Apple Developer

  • How can I notice whether a class is loaded or not?

    In the case of a instance, finallize() method can do it. But when it is a class?
    Does anyone know the way?

    In old JVM, the gc will collect any classes without any reference, however, JDK1.2 uses a new tech to collect classes, that is only if all classes that loaded by the same class loader do not have any reference to them, they are unloaded. So, in JDK1.2, if all you classes are loaded by the same class loader, once the class is loaded, it will be there untill you exit the program. Only if you use your own class loader to load some classes, or the application is a distributed application (that is, multiple JVMs are in use), the class unload and reload could be a problem.
    There is no direct finalize thing for classes, maybe JVM profile could help, since some application can use it to analysis the running program's memory usage (includes classes loaded). Or maybe a customized class loader could help. I'm not sure. Also the static initial codes could let you know the class is re-loaded, though it can't tell you when the class is un-loaded.

  • How can I check if a function is or is not called from the event listener? in Flash CS4 (AS3)

    Hi,
    I came across a little problem.
    I put an event listener inside a for loop and the for loop inside a function.
    I want the for loop to end as soon as the event listener inside the for loop calls its function.
    Here is the general code for a better picture.
    Code:
    this.addEventListener(Event.ENTER_FRAME, function#1);
    function function#1(event:Event):void{
              if(something is true){
                        for(var i = 0; i < numOfmy_mcs; i++){
                                  this["my_mc_"+String(i)].addEventListener(MouseEvent.CLICK, function#2);
    function function#2(e:Event):void{
    //do something cool here
    Thank you for any help!

    kglad wrote:
    that for-loop (if it executes), defines listeners for interactive objects.  that will complete long before any object is clicked.
    Well yes but it does it again and again (frames per second times seconds = number of times it goes through the code if i'm not mistaken), because it is inside a function, and through testing i found out that it works like this:
    Example:
    there are 5 my_mc's in my project: (my_mc_0, my_mc_1, my_mc_2, my_mc_3, my_mc_4)
    if i click my_mc_0 function#2 is called and executed. BUT only after the loop finishes (i know this from tons of testing)...which is unnecessary since you cannot click two places at once. This might not be a problem in this example because i am only using 5 my_mc's buy if i use 500000000 my_mc's it would make a lot of difference.
    is there a way to stop the loop if the function is called?
    ...maybe there is a better way to write it, the only alternative i know that works is if i manually write every single listener and this also is logical in this example but as i said next to impossible if the numbers get bigger.
    -Note
    I didn't specify this earlier but function#2 makes the if statement false so it wont jump back into it.
    Thank you for the help I really appreciate it!
    3rd edit...don't know what's wrong with me

Maybe you are looking for

  • Monitor no longer recieves video signal [Solved... w/ Fire.]

    Greetings and thanks in advance for reading.  I'm thinking the problem is either Video or Processor but second opinions are always appreciated: The problem started about a week ago when I was playing Wizardry 8 via Cedega (OpenGL accelerated Game.) 

  • Apple Service At Genius Bar

    I recieved an iPhone 5 for my birthday last week, and on the same day my mother put a horrid deep scratch right down the screen! I booked a genius session in my local apple store, and without any hesitation or questioning they replaced my iPhone with

  • RSS PHP Help...

    Ok, well I am making a PHP rss reader for my website with updating feeds using this website... http://rssfeedreader.com/php.html#HTML It has worked so far and I have followed the instructions but I get these errors when I try to view the page that vi

  • How to stop aperture from looking for mobile me?

    I can't access the preferences.  It is stuck on Web and keeps looking for mobile me galleries eventhough I've disabled mobile me under File > Web Accounts.  I've also disabled Facebook...  I can't deselct the automatically check for albums check box.

  • After new update my back up is freezing up

    I was able to download the new update with no problem.  When I try and sync my phone now, it acts like its backing up but never progesses.