Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.3.7, 1.4.6, 1.5.8
-
None
Description
If we use the getString() method to get the value from a ResultSet for a integer column with the zerofill option the value we obtain doesn't have the expected leading zeros.
We can reproduce the behavior with the next snippet:
{
Connection connection = DriverManager.getConnection (connectionString, user, password);
Statement st = connection.createStatement();
st.executeUpdate("drop table if exists tmpTest;");
st.executeUpdate("create table tmpTest (id int unsigned primary key auto_increment, value smallint(3) unsigned zerofill not null unique);");
st.executeUpdate("insert into tmpTest(value) values (1), (4), (5), (8);");
PreparedStatement pst1 = connection.prepareStatement("select value from tmpTest");
ResultSet rs1 = pst1.executeQuery();
while(rs1.next())
rs1.close();
pst1.close();
st.close();
connection.close();
}
Using the 1.1.8 or 1.2.3 versions of the connector this returns the expected result:
Value: 001
Value: 004
Value: 005
Value: 008
In any version after 1.3.0 the behavior changes:
Value: 1
Value: 4
Value: 5
Value: 8