Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java &引用;用户缺少权限或找不到对象“;从spring执行sql脚本时_Java_Spring_Hibernate_Junit_Spring Test - Fatal编程技术网

Java &引用;用户缺少权限或找不到对象“;从spring执行sql脚本时

Java &引用;用户缺少权限或找不到对象“;从spring执行sql脚本时,java,spring,hibernate,junit,spring-test,Java,Spring,Hibernate,Junit,Spring Test,我正在使用Hibernate3和Spring3。我一直在尝试填充内存中的数据库,我正在使用Spring来实现这一点。当我尝试这样做时,我感到非常沮丧,这个堆栈跟踪:为了节省你们一些阅读,例外是: user lacks privilege or object not found: XFC_ACTIONSTARTCONDITIONTYPE Failed to execute database script; nested exception is org.springframework.jdb

我正在使用Hibernate3和Spring3。我一直在尝试填充内存中的数据库,我正在使用Spring来实现这一点。当我尝试这样做时,我感到非常沮丧,这个堆栈跟踪:为了节省你们一些阅读,例外是:

user lacks privilege or object not found: XFC_ACTIONSTARTCONDITIONTYPE  

Failed to execute database script; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource [ctl_data-scrubd.sql]: INSERT INTO xfc_ActionStartConditionType (actionStartConditionTypeId,actionStartConditionTypeName) VALUES ('1','Start After Action Completed')" type="org.springframework.dao.DataAccessResourceFailureException">org.springframework.dao.DataAccessResourceFailureException: Failed to execute database script; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource [ctl_data-scrubd.sql]: INSERT INTO xfc_ActionStartConditionType (actionStartConditionTypeId,actionStartConditionTypeName) VALUES ('1','Start After Action Completed')
at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:57)
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.initDatabase(EmbeddedDatabaseFactory.java:136)
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.getDatabase(EmbeddedDatabaseFactory.java:111)
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder.build(EmbeddedDatabaseBuilder.java:113)
at com.capitaliq.loader.persistence.PersistenceHelper.setUpSessionFactory(PersistenceHelper.java:123)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement at line 1 of resource class path resource [ctl_data-scrubd.sql]: INSERT INTO xfc_ActionStartConditionType (actionStartConditionTypeId,actionStartConditionTypeName) VALUES ('1','Start After Action Completed')
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.executeSqlScript(ResourceDatabasePopulator.java:198)
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:132)
    at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:45)
Caused by: java.sql.SQLException: user lacks privilege or object not found: XFC_ACTIONSTARTCONDITIONTYPE
    at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
    at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
    at org.hsqldb.jdbc.JDBCStatement.executeUpdate(Unknown Source)
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.executeSqlScript(ResourceDatabasePopulator.java:184)
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: XFC_ACTIONSTARTCONDITIONTYPE
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.SchemaManager.getTable(Unknown Source)
    at org.hsqldb.ParserDQL.readTableName(Unknown Source)
    at org.hsqldb.ParserDML.compileInsertStatement(Unknown Source)
    at org.hsqldb.ParserCommand.compilePart(Unknown Source)
    at org.hsqldb.ParserCommand.compileStatements(Unknown Source)
    at org.hsqldb.Session.executeDirectStatement(Unknown Source)
    at org.hsqldb.Session.execute(Unknown Source)
我暂时想说我的问题是没有创建表,但我不确定。我已经遵循了创建数据库的所有方向,在阳光下的每个组合都不会起作用。 以下是my context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans default-lazy-init="true" xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:jdbc="http://www.springframework.org/schema/jdbc"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<tx:annotation-driven transaction-manager="transactionManager"/>


<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">    <!---->
    <property name="driverClassName" value="org.hsqldb.jdbc.JDBCDriver"/>
    <property name="url" value="jdbc:hsqldb:mem:mydb;create=true"/>
    <property name="username" value="sa"/>
    <property name="password" value=""/>

</bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="configLocation" value="hibernate.cfg.xml.incDTD"/>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.connection.shutdown">true</prop>
        </props>
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

<!--    <jdbc:initialize-database data-source="dataSource" enabled="#{systemProperties.INITIALIZE_DATABASE}" ignore-failures="ALL">
    <jdbc:script location="classpath:ctl_data-scrubd.sql" />
</jdbc:initialize-database>-->




<bean id="dataSourceInitializer" class="org.springframework.jdbc.datasource.init.DataSourceInitializer">
    <property name="dataSource" ref="dataSource"/>
    <property name="databasePopulator">
        <bean class="org.springframework.jdbc.datasource.init.ResourceDatabasePopulator">
            <property name="sqlScriptEncoding" value="UTF-8"/>
            <property name="scripts">
                <list>
                    <value>classpath:ctl_data-scrubd.sql</value>
                </list>
            </property>
        </bean>
    </property>
</bean>
</beans>

org.hibernate.dialogue.hsql方言
创造
真的
真的
类路径:ctl_data-scrubd.sql

我只想使用脚本文件来填充这个数据库。不要说我的sql是错误的,因为我知道事实并非如此。有人有什么想法吗?

把这件事说成是宇宙之谜;我从来没有让它工作过。只是重新定义了我填充表格的方式

必须使用@column注释显式定义列的名称

范例

@Column(name = "column-name")
private String domainName;
在“column name”中,必须替换为初始脚本中设置的名称,不应为CAMELLE。“域名”是应用程序中的属性名


关于

您正在使用哪个版本的HSQLDB?@Alex,来自MANIFEST.MF:规范版本:2.0.1-rc2规范供应商:HSQL开发组实施标题:标准运行时实施版本:2.0.1-rc2实施供应商:HSQL开发组So版本2.0.1-rc2