commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31197] - New implementarion in commons-beanutils
Date Mon, 13 Sep 2004 15:06:13 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31197>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31197

New implementarion in commons-beanutils

fabiolourencetti@uol.com.br changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      everconfirmed|0                           |1



------- Additional Comments From fabiolourencetti@uol.com.br  2004-09-13 15:06 -------
I'm facing a problem with beanutil using jtds jdbc driver (an open source 
driver for sql server.)

The problem occurs in the class BasicDynaBean, method set(String name, Object 
value) when using this code below

org.apache.commons.beanutils.RowSetDynaClass rsdc =
    new org.apache.commons.beanutils.RowSetDynaClass(resultSet);

When a column is of "text" type, jtds driver returns a java.sql.Clob java type 
and it throws a ConversionException ("Cannot convert value of type '...clob 
implementarion...' to property '...' of type 'java.lang.String');

I made an implementarion to this method as follows below. What do you think 
about?

Tks.
Fabio
Sao Paulo/Brazil

-------------------------------
    public void set(String name, Object value) {

        DynaProperty descriptor = getDynaProperty(name);
        if (value == null) {
            if (descriptor.getType().isPrimitive()) {
                throw new NullPointerException
                        ("Primitive value for '" + name + "'");
            }
        } else if (!isAssignable(descriptor.getType(), value.getClass())) {
            if(value instanceof Clob &&
               descriptor.getType() == java.lang.String.class) {
                try {
                    value = ((Clob)value).getSubString(1, (int)((Clob)
value).length());
                }
                catch(SQLException ex) {
                    throw new ConversionException("Cannot convert value of 
type '" +
                            value.getClass().getName() +
                            "' (CLOB) to property '" + name + "' of type '" +
                            descriptor.getType().getName() + "'");
                }
            }
            else {
                throw new ConversionException("Cannot assign value of type '" +
                        value.getClass().getName() +
                        "' to property '" + name + "' of type '" +
                        descriptor.getType().getName() + "'");
            }
        }
        values.put(name, value);

    }

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message