JDBC Auto-Gen Keys2

Go back to: Code Samples
// insert row AND retrieve key
int rowcount = stmt.executeUpdate(
   "INSERT INTO LocalGeniusList (name) VALUES ('Karen')",
    Statement.RETURN_GENERATED_KEYS);
ResultSet rs = stmt.getGeneratedKeys();
// key is available for future queries




Like what you see? Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis

Book Content Copyright © 2009 by Prentice Hall PTR. All rights reserved. | Corporate Sponsor DataDirect Technologies.