db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Remijan <mjremi...@live.com>
Subject Embedded database, authentication, and derby.system.home
Date Fri, 19 Mar 2021 14:05:44 GMT
Greetings,

I have an interesting issue I just ran into and it took a little while to debug and figure
out exactly what is happening.

I have a project that uses an embedded Derby database.  My project folder organization is
a typical for an open source project:

/projectname
   /bin
       start.sh   // starts the application
  /data
     /projectdb  // this is the derby database.

My projectdb database also has a specific username, password, and permissions/roles on that
user.

When I start the application, the "start.sh" script sets the -Dderby.system.home to the "/data"
directory and my JDBC connection URL figures out the fully qualified location of the "/projectdb"
directory so Derby can easily access it. This all works perfectly fine.

Then I wanted to run a test where I moved the /projectdb directory to a different location.
I though  I would be able to do this with no problems. But I was wrong :( When I do this I
get the following authentication exception

Caused by: java.sql.SQLNonTransientConnectionException: Connection authentication failure
occurred.  Reason: Invalid authentication..
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.checkUserCredentials(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
        at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source)
        at org.apache.derby.jdbc.InternalDriver$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.apache.derby.jdbc.InternalDriver.getNewEmbedConnection(Unknown Source)
        at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
        at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
        at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at org.ferris.resiste.console.sql.SqlConnectionProducer.postConstruct(SqlConnectionProducer.java:31)
        ... 67 more
Caused by: ERROR 08004: Connection authentication failure occurred.  Reason: Invalid authentication..
        at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown
Source)
        ... 84 more

Which I thought was kind of odd. What I eventually discovered is the -Dderby.system.home value
and the location of the database must be in sync. If they are not, I get the authentication
exception. If do not set the -Dderby.system.home value, I get this authentication exception.

Originally, I remember setting the -Dderby.system.home value because I wanted the derby.log
files created in that directory. I didn't expect this value would also be critical for connecting
to the database with a username/password.  I haven't tried it unauthenticated, but it seems
to me I should be able to move the location of the database around and as long as I'm connecting
to the database, authentication should work OK regardless of -Dderby.system.home and the location
of the database being in sync.  This make sense?

Thanks!
Mike

Mime
View raw message