Reputation: 1
I'm trying to connect perform an integration test and for that I need the H2 db to recreate some views.
I am using these properties:
<bean id="internalXaDataSource" class="org.h2.jdbcx.JdbcDataSource">
<property name="URL" value="jdbc:h2:./target/testing/h2db/#{randomUUID1.toString()}/:testdb;MODE=MSSQLServer"/>
<property name="description" value="#{randomUUID1.toString()}jdbcXa"/>
<property name="user" value="sa"/>
<property name="password" value=""/>
</bean>
<bean id="h2Server" class="org.h2.tools.Server" factory-method="createTcpServer" init-method="start" destroy-method="stop">
<constructor-arg>
<array>
<value>-tcp</value>
<value>-tcpAllowOthers</value>
<value>-tcpPort</value>
<value>8043</value>
</array>
</constructor-arg>
</bean>
I've tried connecting in several different ways:
then connecting to it with a jdbc connection URL like:
jdbc:h2:./target/testing/h2db/#3434-sdfjsd9o3849-df34/:testdb;MODE=MSSQLServer
I have a successful connection but the DB is empty, no tables are shown. However, using the information schema to get the list of schemata in the database shows that the testdb database is there.
I've tried several different URLs, but none connect. e.g.
jdbc:h2:tcp://localhost:8043/testdb:public;LOCK_MODE=0
jdbc:h2:tcp://localhost:8043/:testdb;LOCK_MODE=0
This is worse - not able to connect - just hangs.
<bean id="internalXaDataSource" class="org.h2.jdbcx.JdbcDataSource" depends-on="h2Server">
<property name="URL" value="jdbc:h2:tcp://localhost:8043/mem:public;MODE=MSSQLServer"/>
<property name="description" value="#{randomUUID1.toString()}jdbcXa"/>
<property name="user" value="sa"/>
< property name="password" value=""/>
</bean>
This also just hangs when trying to connect.
Can you explain what am I doing wrong? Thanks
Upvotes: 0
Views: 1410
Reputation: 1
Figured this out. Had paused the running integration test with the IntelliJ debugger so I could connect to H2. However the breakpoint setting was set to stop the entire JVM. Fixed by editing the breakdown setting in IntelliJ to only pause the thread. Then was able to connect via the third method above.
Upvotes: 0