aspose file tools*
The moose likes JDBC and the fly likes use of serail key (auto increment) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "use of serail key (auto increment)" Watch "use of serail key (auto increment)" New topic
Author

use of serail key (auto increment)

pritam mungse
Greenhorn

Joined: May 21, 2002
Posts: 3
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?


rgds,<br />pm.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 566
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.


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Kel Walker
Greenhorn

Joined: Apr 04, 2002
Posts: 19
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

Joined: Jul 09, 2001
Posts: 1879

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use of serail key (auto increment)