This feature load only a specific column from your MySQL database into jComboBox element in Java. The same from other programming languages, jComboBox display a list of text.
This tutorial shows how to load specific data from MySQL database to jCombox element. The jCombox can be added to a JFrame form or JInternalFrame form.The code uses a while loop, meaning if the query is valid, it will display all row data according to the query settings. Don't forget that this project is created in Netbeans and make sure you are using a Netbeans IDE.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
String sql="SELECT * FROM tablename"; | |
pst=conn.prepareStatement(sql); | |
rs = pst.executeQuery(sql); | |
while(rs.next()){ | |
office.addItem(rs.getString("Description")); | |
} | |
}catch(SQLException e) { | |
JOptionPane.showMessageDialog(this, e.getMessage()); | |
} |
0 Comments