urgent
posted 23 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
hi
i have trying to acess some attributes using the jdbc connection in servlet.Based on the result set value i want to retrieve the value of some other attributes in another table .and print all the attributes from both queries in 1 table .Please tell me how to do this .i am able to get the attributes from one table but not able to connect to another result set it is giving me errors.the code is
stmt=con.createStatement();
String que="select L.registerno,L.bldgno,L.aptno from Lease L where L.leasestart='"+d1+"'" ;
rs=stmt.executeQuery(que);
while(rs.next())
{
int regno=rs.getInt(1);
int blno=rs.getInt(2);
int apno=rs.getInt(3);
pw.println("<tr>");
pw.println("<td>");
pw.println(regno);
pw.println("</td>");
pw.println("<td>");
pw.println(blno);
pw.println("</td>");
pw.println("<td>");
pw.println(apno);
pw.println("</td>");
pw.println("</tr>");
stmt1=con.createStatement();
String que1="select PT.pname,PT.contactinfo from ProspectiveTenant PT where PT.registerno="+regno;
rs1=stmt1.executeQuery(que1);
String pnam=rs1.getString(1);
int cfo=rs1.getInt(2);
pw.println(pnam);
pw.println(cfo);
Here i am getting the value of regno but i dont know how to implement the second result set .please tell me how to do that
Thanks in advance
Lakshmi
i have trying to acess some attributes using the jdbc connection in servlet.Based on the result set value i want to retrieve the value of some other attributes in another table .and print all the attributes from both queries in 1 table .Please tell me how to do this .i am able to get the attributes from one table but not able to connect to another result set it is giving me errors.the code is
stmt=con.createStatement();
String que="select L.registerno,L.bldgno,L.aptno from Lease L where L.leasestart='"+d1+"'" ;
rs=stmt.executeQuery(que);
while(rs.next())
{
int regno=rs.getInt(1);
int blno=rs.getInt(2);
int apno=rs.getInt(3);
pw.println("<tr>");
pw.println("<td>");
pw.println(regno);
pw.println("</td>");
pw.println("<td>");
pw.println(blno);
pw.println("</td>");
pw.println("<td>");
pw.println(apno);
pw.println("</td>");
pw.println("</tr>");
stmt1=con.createStatement();
String que1="select PT.pname,PT.contactinfo from ProspectiveTenant PT where PT.registerno="+regno;
rs1=stmt1.executeQuery(que1);
String pnam=rs1.getString(1);
int cfo=rs1.getInt(2);
pw.println(pnam);
pw.println(cfo);
Here i am getting the value of regno but i dont know how to implement the second result set .please tell me how to do that
Thanks in advance
Lakshmi
posted 23 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Lakshmi
what is the actual Exception you are getting? If the code you posted is the code you are running you'll get an error if there is no resultset returned from your second query.
You could just do a JOIN on the two tables and get the records in one trip:
Something like this:
String que="select PT.pname,PT.contactinfo, L.registerno,L.bldgno,L.aptno from Lease L INNER JOIN ProspectiveTenant PT ON L.registerno = PT.registerno where L.leasestart='"+d1+"'" ;
hope that helps
Also, this is more of a JDBC question.
[ April 19, 2002: Message edited by: Dave Vick ]
what is the actual Exception you are getting? If the code you posted is the code you are running you'll get an error if there is no resultset returned from your second query.
You could just do a JOIN on the two tables and get the records in one trip:
Something like this:
String que="select PT.pname,PT.contactinfo, L.registerno,L.bldgno,L.aptno from Lease L INNER JOIN ProspectiveTenant PT ON L.registerno = PT.registerno where L.leasestart='"+d1+"'" ;
hope that helps
Also, this is more of a JDBC question.
[ April 19, 2002: Message edited by: Dave Vick ]
Dave
posted 23 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I will move it to JDBC.
"JavaRanch, where the deer and the Certified play" - David O'Meara
| Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry. The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










