I have run into a problem that I can't seem to get past with H2
running as a server, containing an in memory database and all the
connections being closed.  The content of the database disapears.

I am running on Solaris with Java 6.  I start H2 as a server from the
command line:

java -cp h2-1.1.117.jar org.h2.tools.server -tcp -tcpPort 8082

I have a Java application that connects and creates an in memory
database in the H2 server:

String url = "jdbc:h2:mem:tcp://localhost:8082/~/
test;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 ";
Class.forName("org.h2.Driver").newInstance();
Connection conn = DriverManager.getConnection(url);

As you can see I try to setup the database so it should withstand all
the connections closing.

I create a table and insert a row:

Statement stmt = conn.createStatement();
stmt.execute("create table testtable (col1 varchar, col2 varchar)");
stmt.execute("insert into testtable (col1, col2) values ( 'Blah',
'deblah'),('bah', 'humbug')");
conn.commit();

I double check that the table and row exist:

String query = "select * from testtable";
ResultSet rs = stmt.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
System.out.println("results");
while (rs.next())
{
    for (int j = 1; j <= rsmd.getColumnCount(); j++)
    {
        System.out.print(rs.getString(j) + " ");
    }
}

My application quits after this.  When I comment out the table create
and insert lines and run the application again I expect it to give me
the same output.  Unfortuantely H2 exceptions with this message:

"Testtable not found"


I assume I am doing something wrong here.  I thought that the
DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1 options in the connection
string would keep the database open and I had assumed any tables in
the database would remain in existence.

Any help is greatly appreciated.


Thanks,
Ty
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to