hi guys, im using the enumeration and hashtable. i have two separate classes wherein in the first one is the retrieving of data from database (the return type is enumeration) and other one is the printing of data..
PHP Code:
try
{
InsertSelect is = new InsertSelect();
Hashtable ht = is.selectData("unitcode", "tblunit");
Enumeration enu = ht.keys();
while(enu.hasMoreElements())
{
ht = (Hashtable)enu.nextElement();
String hehe =ht.get("field").toString();
//cmbUnit.addItem(ht.get("field"));
System.out.println(hehe);
}
}
PHP Code:
public class InsertSelect {
public InsertSelect() {}
public Hashtable selectData(String field, String table){
Hashtable hashSelect = new Hashtable();
String query = "SELECT "+ field +" " + " FROM " +table;
connection con = new connection();
try{
Statement st = con.getCon().createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
hashSelect.put("field",field);
}
}
catch(Exception e){System.out.println(e.getMessage());}
return hashSelect;
}
}
when i run the program i got the error: java.lang.String cannot be cast to java.util.Hashtable
so what will i do? im new here?