Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing The ResultSet

 
Raymond O'Leary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys me again!
Here I'm trying to store the sole result into a string called ans, and use the string in another query. as dar as i can tell the ans string isn't getting any values? Can anybody shed some light on this? Thanks guys.
 
eammon bannon
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your SQL actually return anything? Have you tried logging what value UName has?
Also, in amongst your out.println stuff, you seem to be trying to use the closed ResultSet rs - this might be where your problem is.
 
Raymond O'Leary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah it returns a value, my problem is putting that value into the string ans and using that value in a further sql statement.
 
eammon bannon
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And your second query? Have you tried running it against the DB?
You still seem to be trying to use a closed ResultSet too...
 
Raymond O'Leary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah second query works perfectly
I put this in batween the selects, and the value is printed out.

Its this bit here! Does it look correct?
[ CODE]
String ans=null;
while(rs.next())
{
ans = rs.getString(1);
}
rs.close(); [/CODE]
and thanks for pointing out the closed rs1 for me.
 
Raymond O'Leary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah its working now.
Thanks for your help buddy.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why don't you use directly:
 
Raymond O'Leary
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All working now thanks for the help guys.
Ray
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic