Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Please help....confused:

 
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thank you
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
ARGH!

http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=7&t=007169
    Bookmark Topic Watch Topic
  • New Topic