Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.1.0
-
None
-
None
-
Tested on Windows and Linux
Description
Query:
select count from table_a;
Retrieve results using:
int count = resultSet.getInt(1);
Problem:
Driver needs to translate index to a column name. In MySQLResultSetMetaData.getColumnName(index), the method getColumnInformation(column).getOriginalName() returns "". If I changed the code to this workaround:
public String getColumnName(final int column) throws SQLException {
String results = getColumnInformation(column).getOriginalName();
if (results == null || "".equals(results))
return results;
}
then it works. This is because getColumnInformation(column).getName() returns "count" which is what is needed in ColumnNameMap.getIndex(name).
I don't know the code deep enough to tell if the workaround above is the best way to address the issue, please advise.
Hi,
does not refer to an actual column in the database.
After reading http://docs.oracle.com/javase/6/docs/api/java/sql/ResultSetMetaData.html , I think you need to use getColumnLabel(), not getColumnName(). count
And .. what was actually the code leading to exception?
Following test actually passes successfully to me (I use "count
" in getInt())
@Test
{ ResultSet rs = connection.createStatement().executeQuery("select count(*) from information_schema.tables"); rs.next(); assertTrue(rs.getInt(1) > 0); assertTrue(rs.getInt("count(*)") > 0); assertEquals(rs.getMetaData().getColumnLabel(1),"count(*)"); }public void conj17() throws Exception