This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
hey guys how we show single resultset on the JSP page I have a bean in which I have get/set method and I'm connecting to database my query is select name , phone from book where id = 9 now I'll only get one recordset so how can I show that recordset pls help me out .. Any sample code will be great Thanks for any Help Regards Preeti
Brian Nice
Ranch Hand
Joined: Nov 02, 2000
Posts: 195
posted
0
Are you talking about in your JSP page? If so, just get the ResultSet from your query: <% Connection conn = <set up connection stuff...> String name=null, phone=null; Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("select name, phone from book where ID = 9"); while (rs.next() ) { name = rs.getString(1); phone = rs.getString(2); } %> .. Name = <%=name%> Phone = <%=phone%> HTH Brian
Preeti Sikri
Ranch Hand
Joined: Mar 01, 2001
Posts: 30
posted
0
thanks for the reply I guess this was the solution
Geoff Tate
Ranch Hand
Joined: Feb 06, 2001
Posts: 55
posted
0
You can also wrap the while loop in an HTML table like so: <table> <% while(rs.next()) { %> <tr> <td> <%= rs.getString("name"); %> </td> <td> <%= rs.getString("phone"); %> </td> </tr> <% } %> </table> note the use of the <%. This kinda breaks the rules of the MVC paradigm, but I have seen so many times now.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR> fantastic, a towel? <HR></BLOCKQUOTE>