i want to start from my JUnit test an in memory db and fill it with data. When i start the server via the h2.bat everything works fine for my JUnit test app.
But when i try to start the server form Java i get some sort of connection problems (when i try to connect to the db by the webinterface i get the gui, but its functionallity is missing/wrong)
code to start the server in the @BeforeClass setup:
args = new String[] { "-tcpPort", "8082","-tcpAllowOthers"};
h2Server = Server.createTcpServer(args).start();
// i also tried the createWebServer but it didn't make any difference
code to open connection once:
String url = "jdbc:h2:tcp://localhost:8082/mem:db1";
h2Connection = DriverManager.getConnection(url,"SA","");
For some reason i either have no connection to the db but more likely there is some sort of connection but, like said i get some undefiend connection problems.
How could i try to achieve the same functionality as when running the h2.bat from cmdline? Do i use wrong parameters on createserver?
Update 1:
I found the problem. It seems that the usage of dbUnit to inject my testdata closed my h2connection unexpectetly (still wondering why this did not happen when running the h2.bat cmdline).
I will try now to run the full in memory mode, if it works i will delete this question or write down the problems and solutions for other users.
Update 2: It works now in full memory mode, i am not sure but for me the core problem seemed to be (which i did not expect) calling:
IDatabaseConnection dBUnitConnection = new DatabaseConnection(h2Connection);
....
dbUnitConnection.close()
also closed my h2connection.
Like said, this did not happen when i run the h2server from cmdline.