rwallacej
asked on
JSP - display single record from database
I have a jsp which needs to be populated with values from a query in an Access database. The query only returns one row.
My jsp consists of text boxes which need to be filled with the fields in the query.
How is this done?
My jsp consists of text boxes which need to be filled with the fields in the query.
How is this done?
ASKER
how do I get a ResultSet? Please give an example , thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<body>
<%
ResultSet rs = //from your Access db
%>
<% while ( rs.next() ){//move resultset onto the next row %>
A line of db stuff <%= rs.getString("id") %><!-- get by column name -->
A line of db stuff <%= rs.getString(2) %><!-- get by column index (start from 1)-->
<% } %>
</body>
</html>
-------------
When you get a resultset, you need to call rs.next() as a query returns a resultset witht cursor positioned before the first row initially. This method works for single or multiple rows.