Reputation: 15310
I want to specify the URL for the jdbc:embedded-database
tag. Is this not possible?
For example, if I have the following in my context:
<jdbc:embedded-database type="HSQL" id="dataSource">
<jdbc:script execution="INIT" location="classpath:com/example/init.sql" />
</jdbc:embedded-database>
It will create an in memory database located at jdbc:hsqldb:mem:dataSource
What I want to do is be able to have a different bean ID and database name...
For example:
<jdbc:embedded-database type="HSQL" id="dataSource" url="jdbc:hsqldb:mem:testdb">
<jdbc:script execution="INIT" location="classpath:com/example/init.sql" />
</jdbc:embedded-database>
Upvotes: 13
Views: 15994
Reputation: 120761
Instead of using jdbc:embedded-database, you can do it with a normal datasource configuration, and spring support for SQL script execution
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc\:hsqldb\:mem\:YOUNAME" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:schema_h2.sql" />
</jdbc:initialize-database>
Upvotes: 16