According to the documentation, one should use URLs like
jdbc:h2:mem:name

so that an H2 database in memory persists accross connections.
However, this does not work with the simple example bellow:

---------------------------
package mytest;

import java.sql.Connection;
import java.sql.SQLException;



import org.h2.jdbcx.JdbcDataSource;
import org.junit.Test;


public class TestH2DataSource {
        @Test
        public void doTest() throws SQLException {
                JdbcDataSource s = new JdbcDataSource();
                s.setURL("jdbc:h2:mem:database");
                Connection c1 = s.getConnection();
                c1.createStatement().execute("create table foo (a integer, b
integer)");
                c1.close();
                Connection c2 = s.getConnection();
                c2.createStatement().execute("insert into foo (a, b) VALUES (1,
3)");
                c2.close();
        }
}


-----------------------------------------------------

The statement insert fails because the table foo does not exist. The
test works correctly if both statements are executed against the same
connection.


Best regards,

Ramon

-- 
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