
How to store the resultset of a query in a hashtable n retrive it into a jsp textfield!!!!!!
datatable
Label value id applno 13434323 123 batchno 4334 123
The database table is similar to the diagram given above??now I want to retrive the value of application no and master no into a jsp page?for this I thought of storing the resultset of my query in a hashtable n retriving bt dont know hw to do it?can u help me??..
My query:"select * from datatable where id="'+id'""
I want to get the values here

Hi Friend,
Try this:
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<html>
<table>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from data where id=1");
Hashtable table=new Hashtable();
int i=0;
while(rs.next()){
table.put("Name",rs.getString("name"));
table.put("Address",rs.getString("address"));
}
Set set = table.keySet();
String str;
Iterator itr = set.iterator();
while (itr.hasNext()) {
str = itr.next().toString();
%>
<tr><td><%=str%></td><td><input type="text" value="<%=table.get(str)%>"></td></tr>
<%
}
%>
</table>
</html>
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.