
Can anybody tell me what is the problem in this code as i am not able to fetch the data from the database and set it into dropdown list in jsp please help
<br/>Customer Name:<select name="name">
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/scs","root","root");
Statement st=con.createStatement();
String sql="select * from staff";
ResultSet rs=st.executeQuery(sql);
while(rs.next()){
//String name = rs.getString("name");
}
%>
<option value="<%=rs.getString("fname")%>"></option>
<%
}catch(Exception e){
}
%>
</select>

hi friend,
I think you did all the steps right but you missed to place the value of resultset between the <option></option> tag.
while(rs.next())
{
String name = rs.getString("name");
%>
<option value="<%=name %>"><%=name %></option>
<%
}
For detail tutorial go through the link JSP Get Data Into Dropdown list From Database

Thanq for reply but sorry i cant understand wht u r trying to say......
<option value="<%=rs.getString("fname")%>"></option>
i hv writn the value in the
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.