You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Christian Kurz <cr...@gmx.de> on 2003/07/11 08:03:12 UTC
AbstractDatabaseAction: Tiny bug? (Fix included)
Hi there,
when reusing some of the AbstractDatabaseAction code, I found that there
might be a tiny problem when working with CHAR fields: is it correct to
retrieve them as Integers? See code snippet below.
Best regards,
Christian
AbstractDatabaseAction.java:
...
case Types.BIT:
value = new Integer(set.getInt(dbcol));
break;
case Types.CHAR:
=> value = new Integer(set.getInt(dbcol));
=> Shouldn't this be: value = new String(set.getString(dbcol)); ?
break;
case Types.STRUCT:
value = (Struct) set.getObject(dbcol);
...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: AW: AbstractDatabaseAction: Tiny bug? (Fix included)
Posted by Joerg Heinicke <jo...@gmx.de>.
Integer is okay: CHAR in SQL means one character. At the moment unicode
is preserved for 65536 (four digits, hexadecimal => 16 ^ 4) different
characters (http://www.unicode.org/charts/charindex.html). These are
mapped to numbers, e.g. € for the euro sign.
For Java it's similar
(http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#9151):
The character '\u20ac' is mapped to the integer 8364. So the char type
is a subset of the int type.
Joerg
Christian Kurz wrote:
> Hi there,
>
> when reusing some of the AbstractDatabaseAction code, I found that there
> might be a tiny problem when working with CHAR fields: is it correct to
> retrieve them as Integers? See code snippet below.
>
> Best regards,
> Christian
>
>
> AbstractDatabaseAction.java:
>
> ...
> case Types.BIT:
> value = new Integer(set.getInt(dbcol));
> break;
> case Types.CHAR:
> => value = new Integer(set.getInt(dbcol));
>
> => Shouldn't this be: value = new String(set.getString(dbcol)); ?
>
> break;
> case Types.STRUCT:
> value = (Struct) set.getObject(dbcol);
> ...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
AW: AbstractDatabaseAction: Tiny bug? (Fix included)
Posted by Christian Kurz <cr...@gmx.de>.
Sorry, forgot to say this applies to 2.0.4
-----Ursprüngliche Nachricht-----
Von: Christian Kurz [mailto:crkurz@gmx.de]
Gesendet: Freitag, 11. Juli 2003 08:03
An: bloritsch@apache.org; balld@apache.org; users@cocoon.apache.org
Betreff: AbstractDatabaseAction: Tiny bug? (Fix included)
Hi there,
when reusing some of the AbstractDatabaseAction code, I found that there
might be a tiny problem when working with CHAR fields: is it correct to
retrieve them as Integers? See code snippet below.
Best regards,
Christian
AbstractDatabaseAction.java:
...
case Types.BIT:
value = new Integer(set.getInt(dbcol));
break;
case Types.CHAR:
=> value = new Integer(set.getInt(dbcol));
=> Shouldn't this be: value = new String(set.getString(dbcol)); ?
break;
case Types.STRUCT:
value = (Struct) set.getObject(dbcol);
...
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org