Description:
I was using Apache Tomcat 4.1.27, Mysql 4.0.15 and MyODBC 3.51.06 to develop a simple database application in Windows 2000. I was doing a Query which retrieved all of the records from the database and I found that if a String type field had only one character in it, such as "a", the value would not be returned. It just came up blank as if nothing was in the field at all.
Through some experimentation, I came to suspect that MySQL connector was the problem, so I tried installing an older version (mysqlodbc 2.5) and the database is returning single character fields as expected now.
How to repeat:
This test program written in JSP should do the trick - just insert a record with only one character in the "field_name" field. If I'm right, that field should turn up blank when you run this:
Driver drv = (Driver)
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:odbc:modem");
Statement stmt = conn.createStatement();
ResultSet results = stmt.executeQuery("SELECT * FROM database_name");
String name;
while ( results.next() ) {
name = results.getString("field_name");
out.println("Name: " + name + "<br />");
}
stmt.close();
conn.close();
Suggested fix:
Eek! I have no idea, I just thought I should bring this to your attention. I'm assuming that there's a loop somewhere that isn't doing it's job quite right, but I am not familiar with the code for MyODBC. Sorry about that, I figure it's better to report this than let it fester.