我打算使用 HSQLDB,我正在尝试使用 ant 的示例。
构建文件:
<target name="create.tables">
<echo>Creating tables using: ${db.driver} ${db.url}</echo>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.username}"
password="${db.password}"
onerror="continue"
src="hsqldb/create_cars.sql">
<classpath refid="hsqldb.database" />
</sql>
</target>
<target name="load.data">
<echo>Load Data Using: ${db.driver} ${db.url}</echo>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.username}"
password="${db.password}"
onerror="continue"
src="hsqldb/load_data.sql">
<classpath refid="hsqldb.database" />
</sql>
</target>
特性:
db.driver=org.hsqldb.jdbcDriver
db.url=jdbc:hsqldb:file:hsqldb/dbcars
db.username=sa
db.password=
create_tables.sql:
CREATE TABLE cars (
id INTEGER NOT NULL PRIMARY KEY,
description VARCHAR(255)
) ;
加载数据.sql:
INSERT INTO cars (id, description) VALUES (1, 'first car') ;
INSERT INTO cars (id, description) VALUES (2, 'second car') ;
create.tables 目标有效,但 load.data 给出此错误:
[sql] java.sql.SQLException: Table not found in statement [ SELECT * FROM cars]