This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC 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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "preparedStament and JDBC 2.0" Watch "preparedStament and JDBC 2.0" New topic
Author

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?

TiA


java amateur
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30353
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: preparedStament and JDBC 2.0