Monday, February 20, 2012

JDBC getBoolean/setBoolean

Hello
When I call stmt.setBoolean(columnIndex, true); The value of "1" in inserted to column.
However when I call rs.getBoolean(column) I get "false". If manually set column value to "true", the returned value of rs.getBoolean will be true.
Thx in advance...Ilja,
We have just shipped a QFE to fix this mess, you can get this by contacting product support directly with the information you have posted.

You can verify that the behavior is what you expect by using our latest community tech preview drop which contains this fix:

http://www.microsoft.com/downloads/details.aspx?familyid=f914793a-6fb4-475f-9537-b8fcb776befd&displaylang=en

Thanks,
Angel|||Hi thx for fast reply.
I think I found reason. Column type must be set to "BIT" in order of using booleans on programming side.
Anyway thx.|||

Using BIT certainly helps since this is the type that maps better to the java boolean type. Unfortunatelly for us the JDBC spec is very clear on the allowed conversions for JDBC drivers.

In the case of getboolean we need to support all of the numeric types and do data dependent conversion (conversions that require that the type contain values that can be converted into boolean) for all character based Sql Server types. Before the QFE I mention above we did not.

Glad to hear this worked out for you, good luck

Angel

No comments:

Post a Comment