db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Pendleton (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6773) Derby throws plain SQLIntegrityConstraintViolationException
Date Sun, 12 Apr 2015 20:00:12 GMT

    [ https://issues.apache.org/jira/browse/DERBY-6773?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14491684#comment-14491684

Bryan Pendleton commented on DERBY-6773:

I've been thinking about the client-server support, on and off, over the last month.

And I've convinced myself that the answer lies in the class

An instance of this class is constructed by the client library when it decodes
an error message received over the DRDA protocol from the server. The
SqlException instance has access to the correct message arguments, because it
uses them to build the complete message on the client side:

    SqlException(LogWriter logwriter,
        ClientMessageId msgid, Object[] args, Throwable cause)

A little bit later, SqlException.getSQLException() gets called, to
construct the java.sql.SQLException that wraps the Derby message:

        SQLException sqle = exceptionFactory.getSQLException(getMessage(), getSQ

What I think we have to do is to extend these two pieces of code so that they:
a) save the "args" in the SqlException instance itself in the constructor, and
b) then pass the "args" to SqlExceptionFactory:getSQLException() so that it
    can use those args to construct a DerbySQLIntegrityConstraintViolationException
   with the right table name and constraint name taken from the args.

Then I think we'll have a complete pattern that will work for generating
Derby-specific SQLException subclasses as we desire, with the additional
information from the args made available as this JIRA issue suggests.

I'll see if I can work up a prototype patch that demonstrates this.

> Derby throws plain SQLIntegrityConstraintViolationException
> -----------------------------------------------------------
>                 Key: DERBY-6773
>                 URL: https://issues.apache.org/jira/browse/DERBY-6773
>             Project: Derby
>          Issue Type: Improvement
>          Components: JDBC
>    Affects Versions:
>         Environment: Windows 7 x86_64, Java
>            Reporter: Jochen Wiedmann
>            Assignee: Abhinav Gupta
>            Priority: Minor
>         Attachments: CallSuper.diff, DERBY6733Repro.java, SamePackage.diff, SharedException.diff,
ant -verbose build all.txt
> If a unique constraint is violated by an insert statement, then Derby throws an SQLIntegrityConstraintViolationException.
The error message contains, in particular, the constraint name and the table name.
> To distinguish between cases with various constraints, Derby should instead throw a subclass
of SQLIntegrityConstraintViolationException, with methods like getConstraintName(), and getTableName().
> See also https://hibernate.atlassian.net/browse/HHH-9516.

This message was sent by Atlassian JIRA

View raw message