我正在使用maven构建项目并收到错误消息:
o.d.database.DatabaseTableMetaData - Cannot find column from ResultSetMetaData
info via DatabaseMetaData. Returning null.
java.lang.IllegalStateException: Did not find column 'T2_PRF_VALUE' for
<schema.table> 'PUBLIC.CDD_PRF_TABLE4' in catalog 'PUBLIC' because names do
not exactly match
我试图深入研究DBUNIT和HSQLDB驱动程序,并没有找到任何方法来解决此警告。
我的设置是(使用maven):
的pom.xml
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.3</version>
<scope>test</scope>
</dependency>
hsqldb.script
SET SCHEMA PUBLIC
ALTER USER SA SET INITIAL SCHEMA PUBLIC
ALTER USER SA SET LOCAL TRUE
GRANT DBA TO SA
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
CREATE MEMORY TABLE PUBLIC.CDD_APP_TABLE1 (id INTEGER, value VARCHAR(20));
CREATE MEMORY TABLE PUBLIC.CDD_APP_TABLE2 (id INTEGER, value VARCHAR(20));
CREATE MEMORY TABLE PUBLIC.CDD_APP_TABLE3 (id INTEGER, value TIMESTAMP);
CREATE MEMORY TABLE PUBLIC.CDD_APP_TABLE4 (id INTEGER, value TIMESTAMP);
CREATE MEMORY TABLE PUBLIC.CDD_PRF_TABLE1 (id INTEGER, value VARCHAR(20));
CREATE MEMORY TABLE PUBLIC.CDD_PRF_TABLE2 (id INTEGER, value VARCHAR(20));
CREATE MEMORY TABLE PUBLIC.CDD_PRF_TABLE3 (id INTEGER, value TIMESTAMP);
CREATE MEMORY TABLE PUBLIC.CDD_PRF_TABLE4 (id INTEGER, value TIMESTAMP);
query.sql的
SELECT T1.VALUE as T1_PRF_VALUE,
T2.VALUE as T2_PRF_VALUE
FROM CDD_PRF_TABLE3 AS T1 inner join CDD_PRF_TABLE4 AS T2
ON T1.ID= T2.ID
Main.java
final public static String URL = "jdbc:hsqldb:res:hsqldb/hsqldb";
final public static String DRIVER = "org.hsqldb.jdbcDriver";
final public static String USERNAME = "sa";
final public static String PASSWORD = "";
final public static String SCHEMA_NAME = "PUBLIC";
public static JdbcDatabaseTester createHsqldbConnection() throws ClassNotFoundException {
return new JdbcDatabaseTester(DRIVER, URL, USERNAME, PASSWORD, SCHEMA_NAME);
}
感谢任何知道如何解决此警告的人。 顺便说一下,我已经看到很多关于这个问题的问题,但没有找到任何好的答案
答案 0 :(得分:0)
不同的JDBC驱动程序返回其ResultSetMetaData.getColumnName(int)调用中的基础列名称或列别名
HSQLDB返回getColumnName(int)调用的基础列名。您可以让HSQLDB返回列别名(如果有),并将连接属性;get_column_name=false
附加到连接URL。请参阅指南:
http://hsqldb.org/doc/2.0/guide/dbproperties-chapt.html#dpc_connection_props