top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to populate drop down list in Java?

+1 vote
587 views

I have a requirement to populate the drop down list I need to load data from a database table to drop down list in java

my database table is this

CREATE TABLE CITY_MASTER_PL(
CITYID BIGINT NOT NULL,
INVENTORY_SOURCE CHAR,
CITY_NAME VARCHAR(250),
STATE_CODE VARCHAR(250),
STATE_NAME VARCHAR(250),
COUNTRY_CODE VARCHAR (250),
COUNTRY_NAME VARCHAR (250),
HOTEL_COUNT BIGINT,
LATITUDE BIGINT,
LONGITUDE BIGINT,
PRIMARY KEY (CITYID)
); 

in this table I need to load all country name state name and city name can any one help me out this thanks in advance

posted Apr 7, 2014 by Shiva Kumar H

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Use this code it might help you

<td>Country <input type="text" name="country" values="">
<select name="com">
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:8080/test","root","root"); 
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from country");
while(rs.next()){
%>
<option value="<%=rs.getString("country")%>"><%=rs.getString("country")%></option>
<%
}
%>
</td>
answer Apr 7, 2014 by Pavan P Naik
...