[ 
http://issues.apache.org/jira/browse/DERBY-819?page=comments#action_12364274 ] 

David Van Couvering commented on DERBY-819:
-------------------------------------------

Hi, Anurag, thanks for this preview, here are some comments

- I don't understand why the getSQLException() method takes both a message 
string and a message id and args.  It would be great if you provided javadoc 
for this method and explained the use of these various parameters.

- In SQLExceptionFactory40, I assume you mean subclasses, not "sunclasses"

- In SQLExceptionFactory40.getJDBC40Exception, you drop the Throwable t 
argument when constructing SQLException: 
  ex = new SQLException(messages, sqlState, severity)

 Why is that?  Can't you use setCause() or pass t in as a parameter so that t 
gets chained to SQLException?  That's very important information and shouldn't 
get lost.

- If I have this right, the exceptionFactory doesn't get initialized until the 
first instance of InternalDriver() is created.  Isn't it possible that 
getExceptionFactory() will return null?  Doesn't this mean that at some point 
during pre-boot I'll get a NullPointerException if I try to throw a 
SQLException?  Is this something that could happen, or are all SQLExceptions 
guaranteed to be thrown only after at least one instance of InternalDriver has 
been created?

Perhaps this is not an issue, but the pattern I proposed in my email does not 
have this potential timing bug, where the exception factory is created as part 
of the static initializer for the InternalDriver class.  I also question 
whether it needs to be part of the InternalDriver at all,  looking at the code, 
there appears to be no dependency on the data or behavior of InternalDriver.   
Usually for a singleton pattern like this you see something like this 
(independent from InternalDriver, and with no dependencies on boot timing):

public class SQLExceptionFactory
{
     private static factory;

      public static SQLExceptionFactory getExceptionFactory()  {
         if ( factory != null )
           createExceptionFactory();

        return factory;
      }

     private static SQLExceptionFactory createExceptionFactory {
         if ( jvmversion >= 1.6 )
            return createJDBC4ExceptionFactory();
        else if ( jvmversion >= 1.4 )
            return createJDBC3ExceptionFactory();
        else
            return createJDBC2ExceptionFactory();
     }
}

Thanks,

David



> Provide JDBC4 SQLException subclasses support in Embedded driver
> ----------------------------------------------------------------
>
>          Key: DERBY-819
>          URL: http://issues.apache.org/jira/browse/DERBY-819
>      Project: Derby
>         Type: Sub-task
>   Components: JDBC
>  Environment: all
>     Reporter: Anurag Shekhar
>     Assignee: Anurag Shekhar
>     Priority: Minor
>  Attachments: derby-819-onlyforreview.diff, derby-819.diff, stat.out
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to