Re: Information in SQLException
- From: "Bjorn Abelli" <bjorn_abelli@xxxxxxxxxxxxxxxxxxxxx>
- Date: 25 Nov 2005 02:31:17 +0100
"IchBin" wrote...
> hombre wrote:
>> The following lines catch what I want:
>> catch( SQLException e ) {
>> if (e.getSQLState() == "23000" && e.getErrorCode() == 1062)
>>
>> But I am not happy with this solution because I have to
>> make code modifications when I switch to another database.
>> I wonder why there is a SQL99 or XOPEN standard that can't
>> be used in practice.
It can, if the vendors and developers follow the standards "by the letter".
Fortunately (or unfortunately, depending on the view), they don't.
SQL is to a large degree built upon Codd's relational algebra, and to a
large degree formed by the use of the "normal forms" (even though they could
be discussed much as such).
I believe the SQLState 23000 never was thought of as anything else than to
enforce a proper use of "integrity constraints", and with the "normal forms"
in mind, there actually shouldn't be more than one unique key in one single
table.
E.g. if you wan't to change the value of a primary key, AFAIK it's possible
to do so, and still keep the integrity towards child tables, through the use
of cascading foreign keys.
But all that just serves as a possible explanation to why the SQLStates are
too "broad" for explicit situations.
> Well the standard applies to the language and not vendor
> generated messages based on there DBMS implementation.
> As a DBMS vendor they can have different feature that
> they need to add their own nomenclatures of messages.
> This will never be standardized. At least it has not
> been in my 28 years of computer field. If you have
> worked with Oracle and than most any other database
> you would understand.
I would say that Oracle has improved in that respect in the last years, as
it now conforms a bit better to the standard than before. I was pretty
excited when they finally decided to implement outer joins in the standard
way...
Unfortunately, their eagerness to conform to standards has also broken a lot
of Java code. When they decided to implement TIME and TIMESTAMP according to
the SQL standard, they also decided to map DATE to java.sql.Date, instead of
java.sql.TimeStamp as they did before...
// Bjorn A
.
- References:
- Information in SQLException
- From: hombre
- Re: Information in SQLException
- From: Bjorn Abelli
- Re: Information in SQLException
- From: IchBin
- Re: Information in SQLException
- From: IchBin
- Re: Information in SQLException
- From: Bjorn Abelli
- Re: Information in SQLException
- From: IchBin
- Re: Information in SQLException
- From: hombre
- Re: Information in SQLException
- From: IchBin
- Information in SQLException
- Prev by Date: Re: Information in SQLException
- Next by Date: Re: DBModelled Storage in JAVA
- Previous by thread: Re: Information in SQLException
- Next by thread: Re: Information in SQLException
- Index(es):
Relevant Pages
|