STEP 1. Write query of jdbc like create connection,statment and result set to get data with in scriptlet code of jsp
code will be like this---
<%
Statement stmt=null;
Connection con=DatabaseConnect.getConnection();
stmt=con.createStatement();
ResultSet resultSet=stmt.executeQuery("select CITY_NAME from city");
%>
Please dont get confuse from jdbc code, i used according to me, but you can write according to you.
Please dont get confuse from jdbc code, i used according to me, but you can write according to you.
STEP 2. Now, write code for dropdownlist
<select class="select2_single form-control" tabindex="-1" name="city">
<option >Select City</option>
<% while(resultSet.next()){ %>
<option><%=resultSet.getString("CITY_NAME") %>
<%} %>
</select>
Note- In database, there is a table CITY, and CITY_NAME is column name.
Thanks
Keep Happy Learning....
No comments:
Post a Comment