Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.1
-
None
-
apache-servicemix-3.1-incubating
database: mysql (with mysql-connector-java-5.0.3 driver)
Description
The first column index in a result from a sql query to database is 1, non 0.
So,
1) in 'getUniqueColumnNames()' method, when we want to get column names from 'metaData' result, we must to start the count in i = 1
[ * metaData.getColumnName(i ); ---> the first column is 1, the second column is 2...] :
BUG:
for (int i = 0; i < metaData.getColumnCount(); i++)
IT SHOULD BE:
for (int i = 1; i <= metaData.getColumnCount(); i++) {
2) in 'toXmlSource()' method:
BUG:
for (int i=1; i<=colCount; i++) { buff.append(colNames[i].toLowerCase() + "='" + rs.getString(i) + "' ");
IT SHOULD BE:
for (int i=0; i<colCount; i++) { buff.append(colNames[i].toLowerCase() + "='" + rs.getString(i + 1) + "' "); --> index in 'colNames' starts in 0 and index in 'rs' starts in 1