Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

preparedStament and JDBC 2.0

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic