watch the video for the designing part!
write the following code inside the class:
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
Create one function and write the following code inside that function!
call this function inside the constructor of that class i.e. under the initComponents();
write the following code inside the class:
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
Create one function and write the following code inside that function!
try
{
con= DriverManager.getConnection("jdbc:mysql://localhost/combobox", "root","");
String sql = "select * from combobox ";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
while(rs.next())
{
String name = rs.getString("fname");
jComboBox1.addItem(name);
}
}catch(Exception ex)
{
JOptionPane.showMessageDialog(null, ex);
}
call this function inside the constructor of that class i.e. under the initComponents();
No comments:
Post a Comment