Win a copy of The Java Performance Companion this week in the Performance forum!
    Bookmark Topic Watch Topic
  • New Topic

Please help....confused:

 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Report post to moderator
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);
 
DC Dalton
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 291
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thank you
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
 
    Bookmark Topic Watch Topic
  • New Topic