日期:2014-05-16  浏览次数:20515 次

Dbunit oracle导出错误

在用springside3.4的时候。把数据库迁移到oracle。修改了连接的一些参数。

执行数据库导出成文本文件的脚本。

报找不到表或者视图的错。是因为权限的关系

在oracle里面用system管理员登录

然后给用户权限

?

grant exp_full_database MINIWEB

?

?以为这样就可以了。没想到还是报错了。

?

org.dbunit.database?
Class AmbiguousTableNameException

查了一下文档上面的说明。是

?

This exception is thrown by?IDataSet?when multiple tables having the same name are accessible. This usually occurs when the database connection have access to multiple schemas containing identical table names.

Possible solutions: 1) Use a database connection credential that has access to only one database schema. 2) Specify a schema name to the?DatabaseConnection?orDatabaseDataSourceConnection?constructor. 3) Enable the qualified table name support (see How-to documentation).

?

?


就是因为没有指明数据库的schema,这个schema默认是和用户名一样的。是一个空间。

类似建用户的时候,把用户建在一个命名空间一样。



修改dbunit的定义

加上schema 就可以了

?

	<target name="exp-db">
		<dbunit driver="${jdbc.driver}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" schema="${oracle.schema}">
			<dbconfig>
				<property name="datatypeFactory" value="${dbunit.datatype}" />
			</dbconfig>
			<classpath refid="project.lib" />
			<export dest="${dbunit.data.dir}/export-data.xml" format="flat" />
		</dbunit>
	</target>
?

?