Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: java.sql.SQLException: No data found


Message #1 by kenneth_a_lee@y... on Mon, 25 Jun 2001 20:04:08
> You can 't retrieve a data base colomn value twice.
> out.print("<td>" + rs.getString("nhours"));
> totalValue = totalValue + rs.getDouble
> ("nhours"));
> 
> The two statement above tries to retrieve value for nhours twice. This 
is 
> wrong. You should copy the value of colomn in a temporary variable and 
then 
> do whatever operations you want with the temporary variable

Amit, 
You are absolutely correct!  Thank you for the information.  After I 
changed my code to store the values into variables, I could use the 
variables how I wanted.  I also found documentation that states that the 
Java standard recommends using a column in a record set once and in left 
to right order to preserve cross platform compatiblity.  (Not that it 
matters since I am using ODBC and tied to one platform, but it gives 
creedence to good programming practices.)  I did use getDate for the date 
value so that I could apply date formatting.  I used getString for 
everything else.  In the code that sums the values, I simple converted the 
resultant string to a double using the static method Double.parseDouble
(<string value>), and then it worked beautifully.

Thanks again,  Ken

  Return to Index