java - dbunit 模式参数不起作用

标签 java maven dbunit

我有以下 dbunit 配置

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>dbunit-maven-plugin</artifactId>
        <version>1.0-beta-3</version>
        <dependencies>
        <dependency>
         <groupId>ojdbc6</groupId>
             <artifactId>ojdbc6</artifactId>
             <version>1.0</version>
             <scope>system</scope>
             <systemPath>${project.basedir}/lib/ojdbc6.jar</systemPath>
         </dependency>
        </dependencies>
        <configuration>
            <driver>oracle.jdbc.driver.OracleDriver</driver>
            <url>jdbc:oracle:thin:@host.com:1521/user</url>
            <username>user</username>
            <password>password</password>
            <format>flat</format>
            <schema>myschemaname</schema>
            <useQualifiedTableNames>true</useQualifiedTableNames> 
            <tables>
                <table>
                    <name>tablename</name>
                </table>
            </tables>
         </configuration>
    </plugin>

当我运行导出目标时,它失败并出现 sql 异常,指出未找到该表。但是,如果我将表名称从 tablename 更改为 myschemaname.tablename 并删除 schema 节点导出可以正常工作。即使我不删除 schema 节点,它也可以正常工作,因此它不会因 myschemaname.tablename 表名而失败。

配置有什么问题?

最佳答案

尝试将 useQualifiedTableNames 设置为 false:

<useQualifiedTableNames>false</useQualifiedTableNames> 

查看 dbunit maven 插件文档 here .

更新:
如果您使用Oracle 10g,您可能需要启用 skipOracleRecycleBinTables还有:

<skipOracleRecycleBinTables>true</skipOracleRecycleBinTables> 

如 DBUnit 文档 here 中所述:

Skip Oracle 10g Recyclebin tables

Enable or disable the processing of oracle recycle bin tables (tables starting with BIN$). Oracle 10g recyle bin tables may break DbUnit's assumption of tables name uniqueness within a schema since these table are case sensitive. Enable this feature for Oracle 10g databases until the bug in the oracle driver is fixed, which incorrectly reports this system tables to DbUnit.

希望这有帮助。

关于java - dbunit 模式参数不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9538961/

相关文章:

java - DBUnit 忽略 xml 元素

junit - DbUnit - 基于非主键字段值删除行

java - Java中无限流的并行处理

Java 替换字符串中的第 N 个特定字符(例如空格)

解析期间的 Javax.ws 编码不兼容

android - Gradle:根据 Maven 本地或远程存储库中的最新版本解决 SNAPSHOT 依赖性

database - 带有 DBUnit 扩展的 PHPUnit 数据库测试

java - 使用 Java 中的方法跳出循环

maven - Gradle:如何将自定义 JAR 文件上传到 Maven 存储库

java - opencsv导入无法解决