Database to GlazedList/Jtable and then edit the database through the GlazedList/JTable?

I had a very similar problem, and I think my result was similar too, except it didn't need reflection (static DB schema). You need to create row objects for each row (which may just include row number and references to a ResultSet and column info) Then write a ca.odell.glazedlists.gui. WritableTableFormat implementation to map these objects to table cells To avoid problems with #2, you can create a flexible row class that fetches column info once from the ResultSet and caches it for reuse Edit: I found an original and simpler implementation (fairly simple) that mine was based upon.

You can view it here: ResultSet Table It might be sufficient for your purposes. Then you add this to the AbstractTableModel implementation provided by the link public void setValueAt(Object ob, int row, int column) throws SQLException { resultSet. Absolute(r+1); if (ob == null) { resultSet.

UpdateNull(column+2); } else { resultSet. UpdateObject(column+2,ob); } rs.updateRow(); this. FireTableCellUpdated(row,column); } public boolean isCellEditable(int row, int col) { return true; } There are three catches though: your ResultSet needs to be updatable, support scrolling both directions, and be sensitive to updates to the DB.

These are part of the JDBC spec, but not all drivers support them, and you need to make sure your ResultSet is created with them enabled. In that case, you just do this. FireTableDataChanged() periodically to force a full update of the table data.It's not the fastest approach, but it does work Edit2: Another approach What about using one of the Object-relational mapper libraries, and then do the ca.odell.glazedlists.gui.

WritableTableFormat like I suggested above?

I had a very similar problem, and I think my result was similar too, except it didn't need reflection (static DB schema). You need to create row objects for each row (which may just include row number and references to a ResultSet and column info). Then write a ca.odell.glazedlists.gui.

WritableTableFormat implementation to map these objects to table cells. To avoid problems with #2, you can create a flexible row class that fetches column info once from the ResultSet and caches it for reuse. Edit: I found an original and simpler implementation (fairly simple) that mine was based upon.

You can view it here: ResultSet Table. It might be sufficient for your purposes. Then you add this to the AbstractTableModel implementation provided by the link.

Public void setValueAt(Object ob, int row, int column) throws SQLException { resultSet. Absolute(r+1); if (ob == null) { resultSet. UpdateNull(column+2); } else { resultSet.

UpdateObject(column+2,ob); } rs.updateRow(); this. FireTableCellUpdated(row,column); } public boolean isCellEditable(int row, int col) { return true; } There are three catches though: your ResultSet needs to be updatable, support scrolling both directions, and be sensitive to updates to the DB. These are part of the JDBC spec, but not all drivers support them, and you need to make sure your ResultSet is created with them enabled.In that case, you just do this.

FireTableDataChanged() periodically to force a full update of the table data. It's not the fastest approach, but it does work. Edit2: Another approach What about using one of the Object-relational mapper libraries, and then do the ca.odell.glazedlists.gui.

WritableTableFormat like I suggested above?

Code snippets would be great or more links. – twodayslate Feb 2 '10 at 21:41 Now, THAT bounty makes it worth digging through source for my old code and combining it to create an implementation. – BobMcGee Feb 3 '10 at 16:37 I only have 53 rep points... I can't do anymore :\ – twodayslate Feb 4 '10 at 3:37 Err, sorry: I'm not being sarcastic.

It IS better than the 15 acceptance points, especially when the question is kind of complex. Question: do you know what DBMS you will be using, and can you guarantee that all the JDBC features will be supported? My previous implementation of an editable table ran to a couple thousand lines, and relied on updatable resultsets and JDBC metadata.

Not all drivers will support these features, but doing it another way is... well, really messy. – BobMcGee Feb 4 '10 at 5:46 1 You can't apply a filter to this, unfortunately.To do that, you need an entity-based approach with one object per row. I've been thinking on a way to do this without the full complexity of a object-relational mapper, but it gets pretty complex pretty fast.

– BobMcGee Feb 19 '10 at 16:00.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions