CREATE TABLE コマンドを含む sql /ddl スクリプトがあります。
私は休止状態を使用しており、休止状態でこのスクリプトを実行してデータベース構造を作成したいと考えています。
これを行う方法?
Spring を使用している場合は、JDBC ユーティリティを使用してデータベースにデータを入力できます。
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<jdbc:embedded-database id="dataSource" type="H2" />
<bean class="org.springframework.jdbc.datasource.init.DataSourceInitializer" depends-on="sessionFactory">
<property name="databasePopulator" ref="resourceDatabasePopulator" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="resourceDatabasePopulator" class="org.springframework.jdbc.datasource.init.ResourceDatabasePopulator">
<property name="scripts">
<array>
<value>classpath*:init-hibernate.sql</value>
</array>
</property>
</bean>
</beans>