mmatthew@stripped wrote:
> On Mon, 3 May 1999, David Pellegrini wrote:
>
> > Hi All,
> >
> > Where is the list of SQLException error codes documented? My search of the
> online manual did not turn up anything.
> >
> > My specific need is to detect when an insert results in a duplicate for a unique
> key/index. I am accustomed (with Oracle) to examining the SQLException's getErrorCode()
> for such matters, but it is
> > returning 0. I suppose I can scan the getMessage() for "Duplicate", but that
> > seems like a kludge ...
> >
> > My config:
> > MySQL 3.22.20a
> > mm.mysql.jdbc-1.2a
> > Blackdown jdk117_v1a
> > Red Hat Linux 5.2
>
> If someone can get me the definitive list of ANSI/SQL error codes I can
> make my driver more compliant. I've been assembling it bits and pieces
> I've found on the net to map some MySQL error codes to ANSI error codes,
> but I haven't found a complete list or specification. The only place I've
> seen to get the whole list is to pay for it from ANSI which is not an
> option for me since I'm developing the driver on my own time and for no
> money :).
>
> -Mark
Mark, you probably don't hear this often enough, but your efforts are greatly appreciated!
I started investigating using the SQLState which is, per the doc I'm reading, " ... a
String object identifying the exception, which follows the X/Open SQLState conventions.
Values for the SQLState
string are described in the X/Open SQL specification." I spent about a half-hour
searching the net for said specification, but didn't find it. I'll look again, and if I
turn up something I'll pass it
along.
While the SQLState carries "industry-standard" values, the errorCode is "... specific to
each vendor. Normally this will be the actual error code returned by the underlying
database." So I would expect
the raw, unmapped MySQL error codes to appear here. With that and a list of MySQL error
codes, I have a fine solution.
I coded around this with ...
if (ex.getMessage().indexOf("Duplicate") != -1)
{
// process the duplicate key situation
}
... and moved on. Is there a better way to to do this?
-davidp
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
DataWeb Systems, Inc.
Database Design / Web Applications / Object Oriented Design
25698 Crestfield Circle, Castro Valley, CA 94552
510.537.1616 voice 510.537.1797 fax
davidp@stripped
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = =