开发者

how to check schema is created or not by <jdbc:embedded-database> tag

开发者 https://www.devze.com 2023-02-12 15:49 出处:网络
i am usingtag for my hsql schema creation. my spring.xml file looks like this: <jdbc:embedded-database id=\"dataSource\" type=\"HSQL\">

i am using tag for my hsql schema creation. my spring.xml file looks like this:

<jdbc:embedded-database id="dataSource" type="HSQL">
    <jdbc:script location="classpath:schema.sql" />
    <!-- <jdbc:script location="classpath:test-data.sql" /> -->
</jdbc:embedded-database>


<bean id="adapterDataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close" depends-on="dataSource">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
    <property name="url" value="jdbc:hsqldb:file:data/db/lmex_adapter_moodle_db" />
    <property name="username" value="SA" />
    <property name="password" value="" />
</bean>

my sql schema file is

create schema lmex_adapter_moodle_db AUTHORIZATION DBA;
set schema lmex_adapter_moodle_db;

drop table moodle_login_credenti开发者_StackOverflow中文版als if exists;


CREATE TABLE moodle_login_credentials (
  moodle_login_credentials_id varchar(40) NOT NULL,
  moodle_username varchar(45) NOT NULL,
  moodle_password varchar(45) NOT NULL,
  host_name varchar(45) DEFAULT NULL,
  port_number varchar(45) DEFAULT NULL,
  database_name varchar(45) DEFAULT NULL
)

while i run my application it runs smoothly with no exception, but when i click submit button and action goes on controller which has a query select * from moodle_login_credentials give me a following exception:

java.sql.SQLException: Table not found in statement [select * from moodle_login_credentials]

so how i can check is my schema file has been created successfully if yes then why i am getting this and how i can resolove this exception.

please help me to resolve this problem

Thank you


Since you are using file-based HSQL, you can just take a look at the files generated:

// this file contaions all executed DDL statements
data/db/lmex_adapter_moodle_db.script 

// this file contaions all executed queries
data/db/lmex_adapter_moodle_db.log 

(paths are relative to the execution directory)

0

精彩评论

暂无评论...
验证码 换一张
取 消