• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

mysql and statement.getGeneratedKeys()

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using mysql jdbc driver 3.0.16
The code inserts a row in a table which has one auto_inc column of type int using a preparedstatement.
The row gets inserted which I can see from the querybrowser but when I do a getGeneratedKeys() on the prepared statement, it returns an empty result set.
Any idea?

I tried execute() instead of executeQuery() but still the same blank resultset.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same problem. Have you gotten an answer to this yet?

Thanks,

Jack
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
execute
int rows = stmt.executeUpdate();
ResultSet rs = stmt.getGeneratedKeys();

use mysql connector J JDBC driver.
Also the application server version matters

For example JBoss 2.x JDBC implementation doesnot support getGeneratedKeys() method.
But JBoss 3.x and above supports.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic