Bug #11798 Calling to setObject(i, bValue, Types.BOOLEAN) throws an exception
Submitted: 7 Jul 2005 20:19 Modified: 17 Oct 2005 19:42
Reporter: Adrián Romero Corchado Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version:mysql-connector-java-3.1.10 OS:Windows (Windows XP)
Assigned to: Mark Matthews CPU Architecture:Any

[7 Jul 2005 20:19] Adrián Romero Corchado
I have a Prepared statement "m_ps"

this call works: m_ps.setBoolean(paramIndex, bValue.booleanValue());
but this other throws an exception: m_ps.setObject(paramIndex, bValue, Types.BOOLEAN);

How to repeat:
execute  m_ps.setObject(paramIndex, bValue, Types.BOOLEAN);

Suggested fix:
add to the method setObject the following lines

                case Types.BOOLEAN:

                    Number parameterAsNum;

                    if (parameterObj instanceof Boolean) {
                        parameterAsNum = ((Boolean) parameterObj).booleanValue()
                            ? new Integer(1) : new Integer(0);

                    switch (targetSqlType) {
                    case Types.BIT:
                    case Types.TINYINT:
                    case Types.SMALLINT:
                    case Types.INTEGER:
                        setInt(parameterIndex, parameterAsNum.intValue());

[9 Jul 2005 9:54] Vasily Kishkin
Could you please provide table definition and test case ?
[9 Jul 2005 13:23] Mark Matthews
This one doesn't need a testcase, it's obvious from inspection. Thanks.