Corrected table name message in dbunit
dbunit data has been populated with lower case table names as per schema definition. Why do you get a corrected table warning every time, I run the scripts for all databases (h2, mysql ..)
[INFO] [dbunit:operation {execution: seed data}] 120 [main] INFO org.dbunit.database.DatabaseDataSet -
databa开发者_如何学Cse name=H2
database version=1.2.128 (2010-01-30)
database major version=1
database minor version=2
jdbc driver name=H2 JDBC Driver
jdbc driver version=1.2.128 (2010-01-30)
jdbc driver major version=1
jdbc driver minor version=2
127 [main] INFO org.dbunit.util.SQLHelper - class org.dbunit.database.DatabaseTableMetaData. Corrected table name:
oldValue=user newValue=USER
Actually DBUnit does mention this.
Here is the javadoc of DatabaseConnection
constructor
... schema - the database schema. Note that the schema name is case sensitive. This is necessary because schemas with the same name but different case can coexist on one database. ...
I guess DBUnit developers correct the schema name case in order to avoid the problem that might cause by this behavior.
DatabaseConnection
is the universal super class of all other database specified DatabaseConnection
, H2DatabaseConnection
for example.
When a DatabaseConnection
is created, DBUnit will retrieve meta data about the database, which is an implementation of java.sql.DatabaseMetaData
by the way, from the jdbc connection.
After that, DBUnit will correct the schema name by checking the metadata, that's the reason you always get the logging messages.
DBUnit use following methods of DatabaseMetaData
to check
boolean storesUpperCaseIdentifiers() throws SQLException;
boolean storesLowerCaseIdentifiers() throws SQLException;
and here is the implementaion of H2 jdbc driver
public boolean storesUpperCaseIdentifiers() {
debugCodeCall("storesUpperCaseIdentifiers");
return true;
}
so the table "user" becomes "USER"
精彩评论