Witam.
Mam takie oto pytanie
Jak uzupełnić comboBoxa wartościami pobranymi z bazy?
Mój kod się prezentuje tak:
Connection connection = null;
ResultSet resultSet = null;
Statement statement = null;
try {
Class.forName("org.firebirdsql.jdbc.FBDriver");
connection = DriverManager.getConnection("jdbc:firebirdsql://localhost:3050/C:/KANTOR.gdb", "sysdba", "masterkey");
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT waluta FROM kantor");
while(resultSet.next()){
jComboBox1.addItem(resultSet.getString(1));
}
} catch (Exception e) {
e.printStackTrace();
jLabel4.setText("Nie pobrano");
} finally {
try {
resultSet.close();
statement.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { }));
Lecz niestety nic się nie wyświetla w combo.. Pomożecie?