Hi, Anurag, this sounds interesting, I generally like this kind of approach over creating hardcoded specific SQLException classes in our code. We should be able to solve this in a way that is less hardcoded and more flexible, which is always good for long-term maintainability.

I don't quite get your approach of having the subclasses of InternalDriver override the getFactory method; how does this work if the method is static? I'm just having trouble picturing what the code looks like to get the right exception.

Just trying to work it out myself, here's a pattern I came up with, where everything's localized in InternalDriver and you don't need to override in the Driver subclasses. It's a pretty standard factory pattern. Would this work?

I was thinking on this line
<code from InternalDriver.java>

private static SQLExceptionFactory excptionFactory;
private static getExceptionFactory () {
   return excptionFactory;
}

public void boot(boolean create, Properties properties) throws StandardException {
       synchronized (InternalDriver.syncMe)
       {
           if (excptionFactory == null)
     *          excptionFactory = createExceptionFactory ();*
           InternalDriver.activeDriver = this;
       }

       active = true;
   }

createExceptionFactory method of InternalDriver will instantiate and return SQLExceptionFactory which will have all the exception related method currently present in Util. Driver40.java will override this method to instantiate SQLExceptionFactory40 which will have additional method to create JDBC40 exceptions.

anurag


Reply via email to