Hi All,

I am encoutering the following exception:
java.lang.NullPointerException
        at 
org.apache.openjpa.jdbc.sql.DB2Dictionary.isDB2ZOSV8xOrLater(DB2Dictionary.java:402)
        at 
org.apache.openjpa.jdbc.sql.DB2Dictionary.createIndexIfNecessary(DB2Dictionary.java:808)
        at 
org.apache.openjpa.jdbc.kernel.TableJDBCSeq.addSchema(TableJDBCSeq.java:244)
        at 
org.apache.openjpa.jdbc.meta.MappingTool.addSequenceComponents(MappingTool.java:612)
        at 
org.apache.openjpa.jdbc.meta.MappingTool.addSequenceComponents(MappingTool.java:594)
        at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:481)
        at org.apache.openjpa.jdbc.meta.MappingTool.run(MappingTool.java:1078)
        at 
org.apache.openjpa.jdbc.ant.MappingToolTask.executeOn(MappingToolTask.java:205)
        at 
org.apache.openjpa.lib.ant.AbstractTask.execute(AbstractTask.java:172)

I don't have a connection to a DB2 server at build time, but I would
like to generate the database schema, just like any of the other
drivers.

I think the problem comes from the following method:
    public boolean isDB2ZOSV8xOrLater() {
       boolean match = false;
       if ((databaseProductVersion.indexOf("DSN") != -1
           || databaseProductName.indexOf("DB2/") == -1)
           && maj >= 8)
           match = true;
        return match;
    }

if the driver is not connected, the metadata cannot be retrieved, so
it is obviously null.

Note that it would be great to get the indexes, as well:
    public void createIndexIfNecessary(Schema schema, String table,
            Column pkColumn) {
        if (isDB2ZOSV8xOrLater()) {
            // build the index for the sequence tables
            // the index name will the fully qualified table name + _IDX
            Table tab = schema.getTable(table);
            Index idx = tab.addIndex(tab.getFullName() + "_IDX");
            idx.setUnique(true);
            idx.addColumn(pkColumn);
        }
    }


so,  it'dbe nice to get rid of the guard to V8 or later in offline mode.

What do you think ?

Niko,

Reply via email to