English 中文(简体)
DbUnit: NoSuchColumnException and case灵敏度
原标题:DbUnit: NoSuchColumnException and case sensitivity

Before posting this I googled a bit, I looked for in dbunit-user archives and a bit also in DbUnit bug list, but I m not found what looking for. Unfortunately, answers here did not help me either.

I m using DbUnit 2.4.8 with MySQL 5.1.x to populate in setUp some JForum tables. The issue is first appearing on jforum_users table created by this script

CREATE TABLE `jforum_users` (
       `user_id` INT(11) NOT NULL AUTO_INCREMENT,
       `user_active` TINYINT(1) NULL DEFAULT NULL,
       `username` VARCHAR(50) NOT NULL DEFAULT   ,
       `user_password` VARCHAR(32) NOT NULL DEFAULT   ,
       [...]
       PRIMARY KEY (`user_id`)
)
COLLATE= utf8_general_ci 
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=14

提出了以下例外情况,作为建立数据库的运作,可予以执行。

org.dbunit.dataset.NoSuchColumnException: jforum_users.USER_ID -
(Non-uppercase input column: USER_ID) in ColumnNameToIndexes cache
map. Note that the map s column names are NOT case sensitive.
       at org.dbunit.dataset.AbstractTableMetaData.getColumnIndex(AbstractTableMetaData.java:117)
       at org.dbunit.operation.AbstractOperation.getOperationMetaData(AbstractOperation.java:89)
       at org.dbunit.operation.RefreshOperation.execute(RefreshOperation.java:98)
       at org.dbunit.AbstractDatabaseTester.executeOperation(AbstractDatabaseTester.java:190)
       at org.dbunit.AbstractDatabaseTester.onSetup(AbstractDatabaseTester.java:103)
       at net.jforum.dao.generic.AbstractDaoTest.setUpDatabase(AbstractDaoTest.java:43)

I looked in AbstractTableMetaData.java sources and nothing seems -statically- wrong. The method

private Map createColumnIndexesMap(Column[] columns)

用途

columns[i].getColumnName().toUpperCase()

in writing map keys. And then the method

public int getColumnIndex(String columnName)

用途

String columnNameUpperCase = columnName.toUpperCase();
Integer colIndex = (Integer) this._columnsToIndexes.get(columnNameUpperCase);

页: 1

I really can t undestand what s going on... Anybody can help me please?

www.un.org/Depts/DGACM/index_spanish.htm Edit after final @limcwer

I m, using a PropertiesBasedJdbcDatabaseer : /code> to configure my DbUnit env, as following:

Properties dbProperties = new Properties();
dbProperties.load(new FileInputStream(testConfDir+"/db.properties"));
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, 
    dbProperties.getProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS));
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, 
    dbProperties.getProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL));
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, 
    dbProperties.getProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME));
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, 
    dbProperties.getProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD));
System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_SCHEMA, 
    dbProperties.getProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_SCHEMA));

databaseTester = new PropertiesBasedJdbcDatabaseTester();
databaseTester.setSetUpOperation(getSetUpOperation());
databaseTester.setTearDownOperation(getTearDownOperation());

IDataSet dataSet = getDataSet();
databaseTester.setDataSet(dataSet);

databaseTester.onSetup();
最佳回答

我有理由相信这一问题源自<条码>用户_id。 页: 1 我过去曾有过类似的问题,在那里,浏览仪表是由服务器库在当地产生的。 I m 现在不是在我的工作桌上,而是尝试这一解决办法,看它是否帮助:rel=“nofollow”http://old.nabble.com/case-sensitative-on-tearDown-td22964025.html

www.un.org/Depts/DGACM/index_french.htm - 02-03-11

我在这里有一个可行的解决办法。 在此,我的标准是:

CREATE TABLE `jforum_users` (
       `user_id` INT(11) NOT NULL AUTO_INCREMENT,
       `user_active` TINYINT(1) NULL DEFAULT NULL,
       `username` VARCHAR(50) NOT NULL DEFAULT   ,
       PRIMARY KEY (`user_id`)
)
COLLATE= utf8_general_ci 
ENGINE=InnoDB
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=14

dbunit-test.xml Test File

<?xml version= 1.0  encoding= UTF-8 ?>

<dataset>
    <jforum_users user_id="100" username="First User" />
</dataset>

http://www.ohchr.org。

Class.forName("com.mysql.jdbc.Driver");
Connection jdbcConnection = DriverManager.getConnection("jdbc:mysql://localhost:8889/test", "", "");
IDatabaseConnection con = new DatabaseConnection(jdbcConnection);

InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit-test.xml");
IDataSet dataSet = new FlatXmlDataSetBuilder().build(is);
DatabaseOperation.CLEAN_INSERT.execute(con, dataSet);

con.close();

我没有发现任何错误,而且该行被输入数据库。

就FYI而言,我确实尝试了REFRESH,并且没有错误就进行罚款:-

DatabaseOperation.REFRESH.execute(con, dataSet);

I m, using DBUnit 2.4.8 and MySQL 5.1.44.

希望这一帮助。

问题回答

I came here looking for an answer to this problem. For me the problem was the Hibernate Naming Strategy. I realised this is the problem as show_sql was true in the Spring s application.properties:

spring.jpa.show-sql=true

我可以看到所生成的一览表,实地名称为FACT_。 NUMBER, rather than factNumber I had in my dbunit s xml.

通过强制实施默认命名战略(从长期来看,缺省似乎为org.hibernate.cfg.ImprovedNamingStrategy,该编码见:

spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.DefaultNamingStrategy

When I got this error, it was because my schema had a not null constraint on a column, but this column was missing from my datafile.

例如,我的表

<table name="mytable">
    <column>id</column>
    <column>entity_type</column>
    <column>deleted</column>
</table>

<dataset>
    <mytable id="100" entity_type"2"/>
</dataset>

我对删除的栏目没有完全限制,在我进行试验时,我获得诺什·科伦特。

当我把数据集改为

<mytable id="100" entity_type"2" deleted="0"/>

我怀着例外。

我面临这一问题,其原因是,我的数据集文档的散射对表格有不同的描述,而后者希望插入数据。

因此,检查你想要填入数据的表格中,有相同的栏目。

当我在卷宗中删除表格中未加插数据的栏目时,问题就消失了。

就我的案件而言,这是在UTF-8中编成的有BOM果实的文件。 我正在使用笔记本来制作剪辑。 避免节省BOM果园。

我有同样的问题,然后图一在我的行文中使用了不同于我在XML档案中的名称。

我确信,在用户_id诉美国ER_ID方面,你会遇到问题。

我只是 st倒了我对这一错误信息的自我。

我不得不扩大旧的法典,我需要在几个表格中增加一个新栏。 在我的一个实体中,我被遗忘为这一栏设立一个setter。 因此,如果是“完整的”,你可以检查贵实体。

有时,它可能像现在这样简单。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签