我的代码有什么问题?
我正在尝试将 mysql 中的数据插入 netbean 的组合框中
private void btnSandoghMousePressed(java.awt.event.MouseEvent evt) {
try {
String query = "SELECT `AccountType` FROM `account`";
con = Connect.ConnectDB();
PreparedStatement stm = con.prepareStatement(query);
pst = con.prepareStatement(query);
ResultSet rs = pst.executeQuery(query);
ArrayList<String> groupNames = new ArrayList<String>();
while (rs.next()) {
String groupName = rs.getString(4);
groupNames.add(groupName);
}
DefaultComboBoxModel model = new DefaultComboBoxModel(groupNames.toArray());
cmbSemetarID.setModel(model);
rs.close();
} catch (SQLException e) {
System.err.println("Connection Error! it's about date");
}
}