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>
H2 is an embedded, open-source, and in-memory database. It is a relational database management system written in Java. It is a client/server application. It stores data in memory, not persist the data on disk.
The Spring JDBC Template has the following advantages compared with standard JDBC. The Spring JDBC template allows to clean-up the resources automatically, e.g. release the database connections. The Spring JDBC template converts the standard JDBC SQLExceptions into RuntimeExceptions.
An embedded database system is a database management system (DBMS) which is tightly integrated with an application software; it is embedded in the application.
NO! Hibernate will execute the SQL statement as it is.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With