Stanley Bradbury wrote:
Thomas Kelder wrote:
Hello,
I'm using Derby in embedded mode, with my databases stored in jar
files. I've set the 'derby.storage.tempDirectory' and
'derby.stream.error.file' properties to writable locations, as advised
in the help file.
When I now perform a query like "SELECT DISTINCT FROM ..." on this
database, it produces the following exception:
ERROR 40XD1: Container was opened in read-only mode.
Whether this exception occurs seems to depend on the number of rows in
the database (e.g. on a small database with ~700 rows everything
worked fine, but on a database with the same schema and about 3000
rows, the exception occured).
I've reproduced it in a testcase:
http://ftp2.bigcat.unimaas.nl/~thomas.kelder/derbytest/DerbyTest.java
Using the following database file:
http://ftp2.bigcat.unimaas.nl/~thomas.kelder/derbytest/testdb.zip
Does anyone have an idea about what causes this error?
Thanks in advance.
Thomas
Hi Thomas -
I looked into this further after I discovered inconsistencies in our
documentation and it making the change I suggested will not correct
your problem (though I still believe that Static properties need to be
set prior to loading the driver). I am looking into this further but
it looks like a bug so far. Thank you for reporting this and
supplying the easy to use test case. I will let you know what I find.
Stan
Some observations:
I am wondering could there be some issue with accessing rows using
INDEXES on such
read-only database.
Simple SELECT * seem to work fine, but using DISTINCTs on the entire
row set fails.
C:\workSP\testDerby>java -Dderby.storage.tempDirectory="c:\temp\derby"
-Dderby.stream.error.file="c:\temp\derby.log" org.apache.derby.tools.ij
ij version 10.2
ij> connect 'jdbc:derby:jar:(testdb.zip)database';
ij> select * from expression where groupid=6339;
ID |CODE
|ENSID
|IDSAMPLE |DATA |GROUPID
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-------------------------------------------------------------------
YPR204W |D
|YPR204W |0
|NA |6339
1 row selected
ij> select distinct id from expression;
ERROR 40XD1: Container was opened in read-only mode.
ij> SELECT DISTINCT groupId FROM expression;
ERROR 40XD1: Container was opened in read-only mode.
On the related topic, looks like only the SHOW TABLES/VIEWS/SYNONYMS
worked on the
readonly database. All other SHOW INDEXES/PROCEDURES/SCHEMAS fails with
NullPointerException.
ij version 10.2
ij> connect 'jdbc:derby:jar:(testdb.zip)database';
ij> show indexes;
ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
The trace looks like:
2007-02-16 20:41:23.475 GMT Thread[main,5,main] (XID = 4), (SESSIONID =
0), (DATABASE = jar:(testdb.zip)database), (DRDAID = null), Failed
Statement is: EXECUTE STATEMENT SYS."getIndexInfo"
java.lang.NullPointerException
at org.apache.derby.impl.sql.compile.ExecSPSNode.generate(Unknown
Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
at
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown Source)
at
org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown Source)
at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.prepareMetaDataStatement(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.prepareSPS(Unknown Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getPreparedQueryUsingSystemTables(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getPreparedQuery(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getPreparedQuery(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.doGetIndexInfo(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getIndexInfo(Unknown
Source)
at org.apache.derby.impl.tools.ij.ij.showIndexes(Unknown Source)
at org.apache.derby.impl.tools.ij.ij.ShowStatement(Unknown Source)
at org.apache.derby.impl.tools.ij.ij.ijStatement(Unknown Source)
at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(Unknown Source)
at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source)
at org.apache.derby.impl.tools.ij.Main.go(Unknown Source)
at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source)
at org.apache.derby.impl.tools.ij.Main14.main(Unknown Source)
at org.apache.derby.tools.ij.main(Unknown Source)
Cleanup action completed
Will post to the list if I find anything else.
-Rajesh