473,320 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

rs.next() returns true, but if (rs.next()) block not executed

In the following method:

Expand|Select|Wrap|Line Numbers
  1. public boolean isMemberAlive(String userSsn) throws SQLException 
  2. {
  3.     boolean isMemberAlive = false;
  4.  
  5.     Connection c = null;
  6.     Statement s = null;
  7.     ResultSet rs = null;
  8.  
  9.     String strSQL = "SELECT Count(*) AS RecordCount " +
  10.         "FROM crs.memmst " +
  11.         "WHERE memmst_ssn = '" + userSsn + "' AND " +
  12.             "(memmst_dt_death IS NULL OR 
  13.             TRIM(memmst_dt_death) = '')";
  14.  
  15.     try 
  16.     {
  17.         c = CnxOracle.getConnection(schema, schemapwd);
  18.         s = c.createStatement();
  19.         rs = s.executeQuery(strSQL);
  20.  
  21.         if (rs.next()) 
  22.         {
  23.             if (rs.getInt("RecordCount") > 0)
  24.             {
  25.                 isMemberAlive = true;
  26.             }
  27.         }
  28.     }
  29.     catch (SQLException exception)
  30.     {
  31.         recordException(exception);
  32.     }
  33.     finally 
  34.     {
  35.         rs.close();
  36.         s.close();
  37.         c.close();
  38.  
  39.         rs = null;
  40.         s = null;
  41.         c = null;
  42.     }
  43.  
  44.     return isMemberAlive;
  45. }
  46.  
At line #21... if (rs.next()) - the resultset contains a record, rs.next() returns true (I checked using a breakpoint), but the statements in the if block are not executed. The code jumps immediately to the finally block.

This is happening in several (new) methods I've written, but older methods containing similar logic / syntax are working fine.

What is wrong???

Thanks,
Woody
Sep 15 '09 #1
3 8960
r035198x
13,262 8TB
Perhaps an exception is being thrown. Put a println in your catch block and see if it executes.
Sep 16 '09 #2
Nope... I put println statements in the if block and the catch block - not executing either of 'em. <sigh>

I'm playing around with Connection scoping, now... I wonder if using these similarly-named connections / statements / resultsets within multiple methods, within multiple DAO's might be introducing a conflict?
Sep 16 '09 #3
r035198x
13,262 8TB
Well if the code is not getting into the if for rs.next() then it means that rs.next() returned false. You made a mistake in your debugging.
Sep 17 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: vakap | last post by:
function show() { var s = '' ; for (var i = 0; i<arguments.length; s += '\n'+arguments) ; typeof(window) != 'undefined' ? window.alert(s) : WScript.Echo(s) ; } function f(){}...
11
by: John Moore | last post by:
Hi, I must be missing something obvious. I cannot get this function to run the update query on Line 6, although the call to run the query evaluates true, and both update_cat_total functions...
4
by: Sly | last post by:
Hi! I am facing an unbreakable wall. I have a class 'x' with one array in it called arr; in Equals(x arg) routine I compare the elements of the array. But first I check whether if( arg.arr ==...
1
by: Tim Begin | last post by:
I am attempting to use the ThreadPool.SetMinThreads method as shown in the MSDN example code: int minWorker, minIOPort; int newWorker,newIOPort; ThreadPool.GetAvailableThreads(out minWorker, out...
59
by: Pierre Quentel | last post by:
Hi all, In some program I was testing if a variable was a boolean, with this test : if v in My script didn't work in some cases and I eventually found that for v = 0 the test returned True ...
12
by: ross.oneill | last post by:
Hi, Is there any function in php that will match a word exactly and if it finds it, it returns true. For example if I search for "CA" strVar = "Bob is from Los Angeles CA" - return true ...
8
by: SupraFast | last post by:
I have two hosting accounts. On one, my setcookie script works fine; cookies are created. On the other, the same script doesn't work. The function returns TRUE, but no cookies is created. I...
9
code green
by: code green | last post by:
I have this piece of code to tidy up after a function that calls move_uploaded_file() if(file_exists($destination.$filename)) { $exitmsg .= "<br>File still in temporary location...
1
by: muthukumaran08 | last post by:
I have textboxes and dropdownlist on my page. And i have image button when i click this image button i m validating textboxes on javascript and if it returns true, i need to do a post back to save...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.