wood burning stoves 2.0*
The moose likes Servlets and the fly likes Please help....confused: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

Please help....confused:

Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Hi Friends,
Here is piece of my servlet from first query I got userID and now I don't know how can I pass "userID" to the second query?
Many thanks for your help,
Elahe
PrepStmt =con.prepareStatement("select userID from user where name =" +name);
while (rs.next()) {
C_BugList xobj=new C_BugList();
xobj.setUserID(rs.getInt("userID"));
}
stmt.close();

//Create a Statement Object
stmt = con.createStatement();
//Second query
PrepStmt =con.prepareStatement("update bug set values (?) where bugNumber="+bugNumber);
PrepStmt.setInt(4,userID);


Thanks,
Elahe
DC Dalton
Ranch Hand

Joined: May 28, 2001
Posts: 287
Instead of using this line:
xobj.setUserID(rs.getInt("userID"))
why not do something like this:
String userID = rs.getInt("userID");
xobj.setUserID(userID);
This way the userID variable is available to your second query.
Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
Thank you
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

ARGH!

http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=7&t=007169
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help....confused:
 
Similar Threads
How to use two query in one servlet
I try to get whole row from database but...
What is wrong with this Update Query!!!!
Please Help(executeQuery)
Am I correct in where clause...