항목을 설정하지만 내 문제가하는 JComboBox에 데이터를 추가하고, 내가 이런 짓을 : main.java :난 자바 응용 프로그램 데이터베이스에서 데이터를 가져 오는 방법을 알고하는 JComboBox
`Interface itself = new Interface();
itself.setComboBoxItems();`
// 호출 방법 setComboBoxItems 여기
는 방법 setComboBoxItems()이다 :
public void setComboBoxItems() {
ResultSet rset = null;
Statement stmt = null;
Connection connect = null;
try {
stmt = connect.createStatement();
rset = stmt.executeQuery("SELECT * FROM DB_Library.dbo.categories");
while(rset.next()) {
String comboItem = rset.getString("categoryName");
System.out.print("now combobox items will run!");
categoriesComboBox.addItem(comboItem);
}
} catch (SQLException ex) {
System.out.print("error from set ComboBox: ");
Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
}
}
하지만, 내가 해결할 수없는 나를 위해
를이 오류를 반환 여기Connection connect = null;
try {
stmt = connect.createStatement();
연결 여전히 null 인 : 당신이 연결을하지 않았다처럼
어떤 오류가 발생합니까? – u449355
우리에게'ex.printStackTrace()'를 표시하십시오. – oliholz
'인터페이스 자체 = 새로운 인터페이스();'는 새끼 고양이를 울게 만듭니다. – Qwerky