File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes preparedStament and JDBC 2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "preparedStament and JDBC 2.0" Watch "preparedStament and JDBC 2.0" New topic

preparedStament and JDBC 2.0

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
pardon my ignorance: i'm using MySql and as a front end a swing app; i display my dinamic queries in JTables.
i wonder if i can take advantage of Updatable Result Sets... and how (i read the java tutorial but only found examples with command line, no table models in the middle...)
i've a table model that receives a resultset and then populates my jtable;
is it possible to have my jTable refreshed whenever i insert i new line in database?


java amateur
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33117

It works the same way as from the command line. The difference is that you need to setup Swing event handlers to update the model and resultset when one or the other changes. I recommend posting in the Swing/AWT forum to ask about this part.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
thanks, Jeanne
i got very discouraged because i tried something along those lines and got this error msg:
com.mysql.jdbc.NotUpdatable: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.

i do use several tabs, so i guess there�s no way...
I agree. Here's the link:
subject: preparedStament and JDBC 2.0
It's not a secret anymore!