
How can i get combo box values from database??
or how can i get values in the drop down menu of the html which is similar to dat of combo box in java - from database?

In Java Swing:
import java.sql.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class JComboBoxExample{
public static void main(String[] args){
JFrame f=new JFrame();
f.setLayout(null);
JLabel lab=new JLabel("Countries:");
final JComboBox combo=new JComboBox();
combo.addItem("--Select--");
try{
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 country");
while(rs.next()){
combo.addItem(rs.getString("countryname"));
}
}
catch(Exception e){}
lab.setBounds(20,20,100,20);
combo.setBounds(120,20,120,20);
f.add(lab);
f.add(combo);
f.setVisible(true);
f.setSize(300,120);
}
}
In JSP
<%@page import="java.sql.*"%>
<select>
<option><--Select--></option><%
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from country");
while(rs.next()){
%>
<option value="<%=rs.getString("countryname")%>"><%=rs.getString("countryname")%></option>
<%
}
%>
</select>

Thanks for the help I will try with the JSP one. If instead of MYSQL if i use microsoft access, what will change?
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.