db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject RE: Database independent error trapping.
Date Mon, 12 Feb 2007 13:52:48 GMT
I do not remember which one, but either hibernate or spring use the same
technique of checking the error code against a map opf known error code and
raise an exception corresponding to the error type. So it can be done, but
it may require a fair amount of work to collect the error codes from the
databases

    Thomas

"Greg Monroe" <Greg.Monroe@DukeCE.com> schrieb am 09.02.2007 15:34:06:

> Three or four years ago, I did some coding on a
> pre-Torque system that tried to deal with this issue.
> One major problem I remember is that there is no true
> standard for SQL error codes.  And what standards there
> are don't seem to be implimented very well (or at all).
>
> To add to the confusion, the error codes are actually
> generated/interpreted by the JDBC layer and not the
> DB vendor.  So, you can't just say "MS SQL does it this
> way", you have to say MS's JDBC driver does it this way,
> Avinar's does it this way, jTDS does it this way, etc.
> I even found some variance in returne codes between driver
> versions by the same vendor.
>
> That said, what I ended up doing in my pre-Torque code
> was to write a bit of "JDBC driver profiler" code that
> ran when the system started up.  This created the set
> of errors my app was concerned with, stored them away,
> and them my error checking code compared to these.
>
> I'm not sure this can be applied to Torque since to find
> the errors, your DB connect account rights have to be able
> to do thingslike create / delete tables, etc. that some
> security folks frown on.
>
> Hmm, I wonder if a new Torque 4 ToDo would be a bit of
> code that wraps any Torque exception with a check against
> an optional application specific SQL RC to Exception type
> mapping. We could supply a "driver mapping" utility to
> generate this mapping file for the most common errors.
>
> Just remember as I said at the start, this is from a
> few years back.  The state of things may have changed.
> (but I know a lot of folks still using old drivers too...)
>
> Greg
>
> > -----Original Message-----
> > From: Christopher Thill [mailto:cthill69@yahoo.com]
> > Sent: Friday, February 09, 2007 6:47 AM
> > To: Apache Torque Users List
> > Subject: Database independent error trapping.
> >
> > I am wondering if there is a way to do database independent
> > error trapping.
> >
> > For example on a table/object that has a unique key I just
> > invoke the .save() method and and trap any exception.  I look
> > at the exception to see if it was a duplicate value in the
> > unique column that caused the error and then explain this to
> > the user in a friendly message.
> >
> > My problem is that I want the system to portable to different
> > database so I do not want to do something
> > like:
> >
> >     eSql = (SQLException) t;
> >     if ( !eSql.getSQLState().equals("23505") )
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> >
>
> Duke CE Privacy Statement
> Please be advised that this e-mail and any files transmitted with it
> are confidential communication or may otherwise be privileged or
> confidential and are intended solely for the individual or entity to
> whom they are addressed.  If you are not the intended recipient you
> may not rely on the contents of this email or any attachments, and
> we ask that you  please not read, copy or retransmit this
> communication, but reply to the sender and destroy the email, its
> contents, and all copies thereof immediately.  Any unauthorized
> dissemination, distribution or copying of this communication is
> strictly prohibited.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message