On Mon, Apr 23, 2012 at 10:50 PM, Rick Hillegas <rick.hille...@oracle.com> wrote: > UserAuthenticator.authenticateUser() can throw a SQLException which explains > that the user doesn't have access to the given database. I find that > SQLExceptions raised by the following code reach the application: [snip]
I just gave this a shot, but it doesn't appear to work, at least not over the client-server connection. I tried it using a mock authenticator: mockery.checking(new Expectations() {{ oneOf(authenticator).authenticateUser("bob", "bob", dbDir.getAbsolutePath(), new Properties()); will(throwException(new SQLNonTransientConnectionException("Database access denied for user bob", "08004.C.3"))); }}); Then when I connect to the database, I do get back SQLState "08004", but it's "08004.C.1" with a different error message to the one I returned. My initial guess would be that Derby swallows the authentication exception on the server side, sends some kind of error code over the wire and then the client driver propagates a brand new exception to the application. TX