HSQLDB使用ant管理新的独立数据库[表中未找到表]

时间:2013-03-11 21:38:21

标签: ant hsqldb

我打算使用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)
) ;

load_data.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]

1 个答案:

答案 0 :(得分:1)

通常这是由与数据库的短持续时间连接引起的。表定义不会保留,以后也无法找到。请参阅您可以使用的连接属性列表:

http://www.hsqldb.org/doc/2.0/guide/dbproperties-chapt.html

然后试试这个:

db.driver=org.hsqldb.jdbcDriver
db.url=jdbc:hsqldb:file:hsqldb/dbcars;shutdown=true
db.username=sa
db.password=

如果不起作用,请尝试:

db.driver=org.hsqldb.jdbcDriver
db.url=jdbc:hsqldb:file:hsqldb/dbcars;hsqldb.write_delay=false
db.username=sa
db.password=