Continuing this question.
My problem is that I can not edit my JTable. I get an exception and the Object value instead of what I should be seeing.
I am using the ResultSet Table code with a MS-Access database and with a few modifications. My code can be found here. I run into an error when I rs.updateRow()
is called. java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
.
I did a google search on this error with updateRow()
and not much came up. The only real answer I saw was to use a prepared statement but I am not a pro with SQL commands.
Also a plus if you could tell me the best approach in making this become a GlazedList so I can filter easily. Unless you can provide me something that filters regular JTables easily.
Trying to offer more help since the initial solution didn't work 100%.
Try the info here: Updatable ResultSets to see how to make your
ResultSet
updatable by specifying arguments when creating aStatement
object from yourConnection
. I realized this option may not have been set by default for you. If you driver supports this mode, it should allow the code to work.EDIT: It's not necessarily the driver (though you will need a JAR if you wish to change that). You need to enable
ResultSet.TYPE_SCROLL_SENSITIVE
when creating the table -- the driver may still support this mode. There are ways to probe what the JDBC driver supports, but they're kind of a pain to use unless you use a GUI like SquirrelSQL Client to get a full list of capabilities.Search the web for a better example of a ResultSetTableModel. I'm sure you will find one that already implements the setValueAt(...) method. Or another approach is to just copy the data from the ResultSet to a DefaultTableModel and then you can edit it no problem.
Have you read the JTable API and followed the link to the Swing tutorial on "How to Use Tables" which contains a working example of sorting, since sorting is a default part of the JDK.