Article View: borland.public.jbuilder.java.language
Article #8626SQLException - determining cause?
From: AJ
Date: Mon, 12 Mar 2001 18:05
Date: Mon, 12 Mar 2001 18:05
12 lines
1464 bytes
1464 bytes
After a call to PreparedStatement.executeUpdate to do an insert, I get an SQLException. How do I determine if this is due to a duplicate key, i.e. the row is already there? Are there sub-types to SQLExceptions? Do I have to look at XOPEN SQL states? I need this to be database independent, so vendor-specific error codes will not help. Bottom line: if the row is duplicate, I want to update instead of insert. I suppose I could just try to update if the insert fails, but I'd like to be sure that I'm only doing so in the specific case of a duplicate row error. Thanks, AJ
Technical Details
Message-ID:
<3aad0fc8$1_2@dnews>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.icl.net!dispose.news.demon.net!demon!grolier!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!204.29.134.21Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,f26c03738229183f,start X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-12 10:20:31 PST From: "AJ" <someone@nospam.com> Newsgroups: borland.public.jbuilder.java.language Subject: SQLException - determining cause? Date: Mon, 12 Mar 2001 12:05:32 -0600 Lines: 15 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 204.29.134.21 Message-ID: <3aad0fc8$1_2@dnews> X-Trace: 12 Mar 2001 10:04:56 -0800, 204.29.134.21 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.icl.net!dispose.news.demon.net!demon!grolier!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!dnews!204.29.134.21