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

ResultSet.updateInt(...) generated sql

 
Thomas Mcfarrow
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21298
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic