This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Error using SCOPE_IDENTITY in java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error using SCOPE_IDENTITY in java code" Watch "Error using SCOPE_IDENTITY in java code" New topic
Author

Error using SCOPE_IDENTITY in java code

Kanchan Singh
Ranch Hand

Joined: Dec 27, 2007
Posts: 38
Hi all

I am creating a prepareStatment which has insert query
and the table it inserts generates an auto increment value.
I want this auto increment value using SCOPE_IDENTITY in same query
my code is


where am I making mistake any suggestion..

Thanks in advance
Regards
kanchan
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, first you create a PreparedStatement using an option that says "Don't return auto-generated keys". Then right after that you use some code that tries to get the auto-generated keys. Looks like an error to me. But there doesn't seem to be anything about SCOPE_IDENTITY in what you posted, so I can't understand why your post title says you are having an error using it.
 
 
subject: Error using SCOPE_IDENTITY in java code
 
Similar Threads
Performance Issues with database insert !!
SELECT SCOPE_IDENTITY()
how to get primary key after doing an insert
Html Input to oracle through servlet and JSP output
Displaying record not exists