I'm looking for a way to display a java.sql.ResultSet on the screen. preferably built-into java or swing. If neither of those have a decent method that's simple, I'd consider spring.
How?
I'm looking for a way to display a java.sql.ResultSet on the screen. preferably built-into java or swing. If neither of those have a decent method that's simple, I'd consider spring.
How?
Loop over the results of you ResultSet and put in into a TableModel.
DefaultTableModel resultSetToTableModel(DefaultTableModel model,ResultSet row) throws SQLException
{
ResultSetMetaData meta= row.getMetaData();
if(model==null) model= new DefaultTableModel();
String cols[]=new String[meta.getColumnCount()];
for(int i=0;i< cols.length;++i)
{
cols[i]= meta.getColumnLabel(i+1);
}
model.setColumnIdentifiers(cols);
while(row.next())
{
Object data[]= new Object[cols.length];
for(int i=0;i< data.length;++i)
{
data[i]=row.getObject(i+1);
}
model.addRow(data);
}
return model;
}
Then you can do something like
JOptionPane.showMessageDialog(null,new JScrollPane(new JTable(model)));
Hopt it helps