
plz correct this one ....i want to retrive data row from databse ...all its working but for combobox it not.......plz plz plz help me......
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
if(jTextField1.getText().equals("")){
JOptionPane.showMessageDialog(null,"Please enter the Student Name to search","Error",0);
}
else{
try
{
String name=jTextField1.getText();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:college");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from demo where name='"+name+"'");
while(rs.next()){
jTextField1.setText(rs.getString("name"));
jComboBox1.setSelectedText(rs.getString("course"));
jTextArea1.setText(rs.getString("address"));
}
}
catch(SQLException sqlex)
{
System.out.println("SQLExceptionOccurred"+sqlex.getMessage());
}
catch(ClassNotFoundException cnfex)
{
System.out.println("ClassNotFoundExceptionOccurred"+cnfex.getMessage());
}
}
}

jComboBox1.setSelectedItem(rs.getString("course"));
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.