user interface - not getting data from SQL to JTable in Java -
i'm trying data database. when program getting data resultset
, doesn't seem getting , @ end data[][]
null
. when debugging, noticed result r currentrow
-1
throughout while loop , isn't changing. don't know how fix this. appreciated!
the code :
//get information table public void view(string table, connection conn) { try { preparedstatement statement = conn.preparestatement("select * " + table + " name '%" + name + "%';"); resultset r = statement.executequery(); data = new string[rows][column]; int j = 0; resultsetmetadata info = (resultsetmetadata)r.getmetadata(); x = new string[column]; for(int = 0; < column; i++) x[i] = info.getcolumnname(i + 1); r.beforefirst(); while(r.next()) { for(int = 0; < column; i++) data[j][i] = r.getstring(x[i]); j++; } } catch(exception e) { system.out.println(e); } }
Comments
Post a Comment