Wednesday 23 November 2016

Converting a ResultSet object a TableModel object using rs2xml.jar file

You can include rs2xml.jar file in your project like below.
Here's the Download Link for rs2xml.jar file.

Once you include the rs2xml.jar file in your project you can convert a resultSet into a TableModel with one statement instead of writing the whole function yourself. You will have to call resultSetToTableModel() method of DbUtils class for this purpose. You will pass a ResultSet object to this method and it will return you a TableModel Object which later you can set as your JTable's model. here's an example where rs is a ResultSet object.

TableModel model = DbUtils.resultSetToTableModel(rs);

Can anyone contribute in it and upload a demo project for this ? Your contribution will give you earns you marks as I told you so keep sharing.

2 comments: