> I tried to increase limits by running this before loading the driver:
> System.setProperty("h2.serverCachedObjects", "20000");
You need to set this property on the server. For example, if you start
the server using the command line, use:
java -Dh2.serverCachedObjects=20000 ...
20000 is probably too much, but let's try. If this is really the
problem then I would like to find out why it fails for you. Could you
please use a higher log level (append ;TRACE_LEVEL_FILE=3 to the
database URL) and post or send me the *.trace.db files from both the
server and the client(s)?
Regards,
Thomas
According to the .trace.db file, this isn't a bug in H2, but actually
a problem in the application. It works for HSQLDB because HSQLDB
doesn't follow the JDBC specification in this case. What happens in H2
is: the application tries to read from a result set that is already
closed, because the the statement that produced the result set was
re-run. This doesn't fail with HSQLDB because it doesn't close the old
result set, which is a violation of the JDBC specification. Test case:
stat.execute("create table test(id int)");
stat.execute("insert into test values(1)");
PreparedStatement prep = conn.prepareStatement("select * from test");
ResultSet rs1 = prep.executeQuery();
prep.executeQuery();
rs1.next();
According to my test, the last line (rs1.next()) fails for H2,
PostgreSQL, MySQL, and Apache Derby (and fail with all databases that
follow the JDBC specification in this regard). It works for HSQLDB.
I found out this is the problem using the .trace.db file:
line 3859: ResultSet rs147 = prep34.executeQuery();
line 3940: ResultSet rs149 = prep34.executeQuery();
line 3952: rs147.next();
The relevant text in the JDBC specification is in the ResultSet class
level Javadoc, "A ResultSet object is automatically closed when the
Statement object that generated it is closed, re-executed, or used to
retrieve the next result from a sequence of multiple results."
By the way, h2.serverCachedObjects only applies to the TCP server (as
documented), but you are using an embedded database, so
h2.serverCachedObjects can't possibly help.
Regards,
Thomas