473,661 Members | 2,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 9012
r035198x
13,262 MVP
Perhaps an exception is being thrown. Put a println in your catch block and see if it executes.
Sep 16 '09 #2
jwdvorak
2 New Member
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 MVP
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
2213
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(){} show('delete(f):',delete(f)) ; // false g = function(){} ;
11
2178
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 execute, while the function itself returns true. A var_dump shows that all the variables are valid, and I can run the exact same update query at the mysql command line without errors. I've
4
3009
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 == null ) { return( false ) ;
1
3771
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 minIOPort); bool flag = ThreadPool.SetMinThreads(4, minIOPort); ThreadPool.GetAvailableThreads(out newWorker, out newIOPort); After running this flag is true, but the worker value is still set to 25. I am using .Net 1.1.4322 and this call was...
59
4577
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 So I changed my test for the obvious "if type(v) is bool", but I still find it confusing that "0 in " returns True
12
2663
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 strVar "Bob is from Canada" -- returns false
8
5865
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 checked to make sure that the variables have values and that the proper expire time is set and etc. Any ideas? <?php foreach($_POST as $name => $value){ if($name == 'hItem'){ $item = $value;
9
8435
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 <br>$filename <br>Attempting deletion "; if(unlink($destination.$filename)) $exitmsg .= '<br>Success deleting. Please try again '; else
1
1705
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 the values. If it is returns false it should not post back. Please do help me on this.
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1740
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.