Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

use of serail key (auto increment)

 
pritam mungse
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
the problem is when we have a serial key in the database, and when we insert a record in that table, how do we access it back. u don't know the value of hte serial key when u insert a record in the table, it is assigned by the database itself.
the problem has some solution in the JDBC driver for the corresponding drivers. e.g. the informix JDBC driver gives specific api to get back the value of the serial field and this works fine in normal scenario. but when we are trying to use the weblogic connection pool, the method given by informix api are not avialable. ( the connection and statement classes are totaly different than the informix respectives, even though the driver specified is the informix JDBC driver.)
can nyone tell me how to overcome this problem?
 
Adam Hardy
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might have to write a stored procedure to return the last index. I don't know informix though, so I don't know what is possible.
 
Kel Walker
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may or may not help.
This is supported in JDBC 3.0.
See the section named 'auto-generated keys' in this article.
Getting upto date with JDBC
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kel Walker:
This may or may not help.
This is supported in JDBC 3.0...

Unfortunately, I haven't seen 1 JDBC 3.0 compliant driver yet.
Oracle will increment the auto number (sequence) on a select using the sequence to obtain it's value, then use the value to write to the database.
You can also handle the autonumber in a class by yourself. If you search the forum, it has been explained in detail in a previous thread.
Jamie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic