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 ResultSet.updateInt(...) generated sql 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 "ResultSet.updateInt(...) generated sql" Watch "ResultSet.updateInt(...) generated sql" New topic
Author

ResultSet.updateInt(...) generated sql

Thomas Mcfarrow
Ranch Hand

Joined: Jul 09, 2001
Posts: 137
Hi,

Currently we are using MySQL and the JDBC connector for our application. In some cases we are doing :

ResultSet rset ....
rset.moveToInsertRow();

...
...
rset.updateInt(...).



I have a simple question, is there a easy way to get the SQL generated by this statement programatically? We are looking at implementing MySQL bin-log alternatives for the app.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Not too likely. The SQL would look something like this:

UPDATE table SET field = value WHERE primarykey = value

Most of that could be done, but your code doesn't know which column is the primary key. MySQL does (if there isn't one, it will complain) but your code doesn't. Unless perhaps you had a convention where the primary key is the first column, or something like that.
Thomas Mcfarrow
Ranch Hand

Joined: Jul 09, 2001
Posts: 137
Basically I am trying to implement a MySQL bin-log that saved in the database. The alternative is to write bridge code that will move the log to a table.

Or remove the updatable resultsets. IMHO, updatable resultsets are slower than a straight insert or update.

The whole idea was not exposing db architecture to the client.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ResultSet.updateInt(...) generated sql