Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

table

 
Jackie Wang
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
say there are two table License, Item
license has column (lic_name, lic_no, create_date)
Item has column(lic_no, item_description)
lic_no join 2 table

i want to write a file which contain license and Item according to the license
i.e.
license A
Item I
Item II
license B
Item III
Item X
license C
Item IV
I have 1 access to DB for getting the license
and then I have access to 3 DB for getting the item according to each license.
Are there a way to grab all Items first?
I am not famliar with the resultset.
Please help.
Thanks! =)
 
Geeta Ramasami
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
U can write a join query to fecth the records from both the tables at a single strech and display it using the resultset
select lic_name, item_description from licence l, Item i where l.lic_no = i.lic_no
Once u execute the query the resutltset will have the expected values

Geeta
 
Jackie Wang
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks geeta
but how i can "execute" the resultset?
thanks!
 
Anita Raj
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//To execute the string, do the following:
try{
String str1="select lic_name, item_description from licence l, Item i where l.lic_no = i.lic_no";
ResultSet rs = stmt.executeQuery(str1);
while(rs.next()) {
String name=rs.getString("lic_name");
String item= rs.getString("item_description");
//write name and item to a file
}
}
[ March 19, 2003: Message edited by: Anita Raj ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic