hello people. i have this application which is suppose to retrieve database tables form a paricular database being used and add them as items in2 a jcombobox.The reason is that i want to hvae the opportunity to insert a file into any table by just clicking my jcombobox and select the desired table to insert it into.
i went as much to write this to test since am doing this for the first time:
try {
JcomboBox jc = new JComboBox();
Class.forName("com.mysql.jdbc.Driver").newInstance();
System.out.println("It loaded ok");
Connection con = DriverManager.getConnection("jdbc:mysql://locahost:3306/db_name","root","");
DatabaseMetaData dbmd = con.getMetaData();
String[] tabtypes ={"TABLES"};
System.out.println("");
System.out.println("TABLE NAMES");
System.out.println("-------------------------------");
ResultSet rs = dbmd.getTables(null,null,null,tabtypes);
while(rs.next())
System.out.println(rs.getString("TABLE_NAME"_);
jc.addItem(rs.getString("TABLE_NAME");
}catch(Exception p){
System.out.println("Exception: " + e.getMessage());
All i get is an error saying; "Illegal operation on an empty set". The most annoying thing is that there are tables present in the db but adding them as items.
Has anyone tried this before?i read a book and i read that some SQL softwares dont allow such access and i'm using MYSQL.
i need help badly.