I'm getting a NPE when I try to connect to a database with securityMechanism=8. This is with Derby 10.3.1.4. I'm setting up the database by creating it, then running the following script from inside my app using the org.apache.derby.tools.ij class:

----------
call syscs_util.syscs_set_database_property(
  'derby.database.propertiesOnly', 'true');
call syscs_util.syscs_set_database_property(
  'derby.authentication.provider', 'BUILTIN');
call syscs_util.syscs_set_database_property(
  'derby.connection.requireAuthentication', 'true');
call syscs_util.syscs_set_database_property(
  'derby.drda.securityMechanism',
  'STRONG_PASSWORD_SUBSTITUTE_SECURITY');
----------

However, when I subsequently close then reopen the database with the following code I get a NPE:

----------
// Try opening the database.
Properties props = new Properties();
props.put("securityMechanism", "8");
props.put("user", dbUser);
props.put("password", dbPass);
Connection db = null;
try {
    StringBuilder sb = new StringBuilder("jdbc:derby:");
    sb.append(dbName);
    db = DriverManager.getConnection(sb.toString(), props);
}
    // Handle exception
}
----------

Stack trace:

----------
java.lang.NullPointerException'. [XJ001]
Caused by: java.sql.SQLException: Java exception: ': 
java.lang.NullPointerException'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
Source)
        at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 
Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown 
Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source)
        at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(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:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:154)
        at org.opensolaris.auth.db.DBManager.openDatabase(DBManager.java:152)
        ... 1 more
Caused by: java.sql.SQLException: Java exception: ': 
java.lang.NullPointerException'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
 Source)
        ... 16 more
Caused by: java.lang.NullPointerException
        at 
org.apache.derby.impl.jdbc.authentication.AuthenticationServiceBase.substitutePassword(Unknown
 Source)
        at 
org.apache.derby.impl.jdbc.authentication.BasicAuthenticationServiceImpl.authenticateUser(Unknown
 Source)
        at 
org.apache.derby.impl.jdbc.authentication.AuthenticationServiceBase.authenticate(Unknown
 Source)
        at 
org.apache.derby.impl.jdbc.EmbedConnection.checkUserCredentials(Unknown Source)
        ... 10 more
----------

Anyone have any suggestions as to where I'm going wrong?  If I remove the
    props.put("securityMechanism", "8");
the code works fine, but I thought it was necessary to have that if you'd configured the database to use STRONG_PASSWORD_SUBSTITUTE_SECURITY? Am I actually setting STRONG_PASSWORD_SUBSTITUTE_SECURITY correctly in the first place in ij script?

Thanks,

--
Alan Burlison
--

Reply via email to