db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alain Kuchta <alain.kuc...@etegent.com>
Subject Unexpected data from ResultSet.getMetaData()
Date Tue, 28 Aug 2012 21:15:28 GMT
Hello all,

I'm developing a tool to move data from a SQL server database to a Derby database using Java.
Both databases have been constructed using through nearly identical (as much as possible)
SQL scripts run through the appropriate means for each engine. One of the initial steps of
my process is to confirm that the schema of the two databases is identically before transferring

This has uncovered some issues.

1) I want to compare the column names in each table to ensure they match. It seems that derby
does not necessarily store column names in the order they were declared at the time of the
tables creation.  Ex.

CREATE TABLE someTable (colA int, colB int, colC int);

For (int i = 1; I < results.getMetaData().getColumnCount(); i++) {
     System.out.print(results.getMetaData().getColumnName(i) + " ");

The output of the java code is not always "colA colB colC", for some tables it is appearing
as "colB colA colC" for example.
When the table is viewed via the ij tool, the columns are in the expected order (the order
they were declared).

2) in a similar vein, .getMetaData().getColumnCount() sometimes returns more columns then
were specified in creation script.

Any help would be much appreciated, and allow me to avoid developing a complicated work-around.

Alain Kuchta

View raw message