sql - Filling combo box throws java.lang.String cannot be cast to java.util.ArrayList -
for time had problem filling in combobox db data, code combo box:
sqlconnect con = new sqlconnect(); sqlutility select = new sqlutility(); arraylist <string> categories = (arraylist) select.select("select category_name gamecategory"); jcombobox combobox = new jcombobox(categories.toarray()); system.out.println(categories); code select in sqlutility
public class sqlutility<t> { private preparedstatement pst = null; private resultset rs = null; private sqlconnect database; public sqlutility(){ database = sqlconnect.getdatabaseconnectioninstance(); } @suppresswarnings("unchecked") public t select(string query) { try { pst = database.conn.preparestatement(query); rs = pst.executequery(); if(rs.next()) { return (t) rs.getstring(1); } } catch (sqlexception e) { e.printstacktrace(); } return null; } i have checked on different class connection works , im able retrieve data, code combobox incorrect, ideas?
Comments
Post a Comment