Subject | RE: [Firebird-Java] Conversions by ResultSet.getter Methods |
---|---|
Author | Rick DeBay |
Post date | 2004-11-19T21:42:36Z |
I was hoping to get back the ascii value of the character. It probably
makes more sense to get back a numeric value.
The problem I have is that I quickly wrote a class that, given a
ResultSet and an object, will use introspection on the object to know
how to get column values from the ResultSet and set them on the object.
If the matching setter for the object takes a char, there is no output
from a ResultSet getter that I can pass in directly to the setter.
BTW, what do you mean by "even more?" I can extend this class to take
advantage of Jaybird enhancements.
-----Original Message-----
From: Roman Rokytskyy [mailto:rrokytskyy@...]
Sent: Friday, November 19, 2004 4:02 PM
To: Firebird-Java@yahoogroups.com
Subject: Re: [Firebird-Java] Conversions by ResultSet.getter Methods
defined as:
public byte getByte() throws SQLException {
if (rs.row[numCol]==null) return BYTE_NULL_VALUE;
try {
return Byte.parseByte(getString().trim());
} catch (NumberFormatException nfex) {
throw (SQLException) createException(
BYTE_CONVERSION_ERROR+"
"+getString().trim()).fillInStackTrace();
}
}
However, if you have a CHAR(1) column containing "Y" as a value,
converting
it to a byte seems problematic. :) Can you suggest what should be the
result
of this conversion?
Roman
Yahoo! Groups Links
makes more sense to get back a numeric value.
The problem I have is that I quickly wrote a class that, given a
ResultSet and an object, will use introspection on the object to know
how to get column values from the ResultSet and set them on the object.
If the matching setter for the object takes a char, there is no output
from a ResultSet getter that I can pass in directly to the setter.
BTW, what do you mean by "even more?" I can extend this class to take
advantage of Jaybird enhancements.
-----Original Message-----
From: Roman Rokytskyy [mailto:rrokytskyy@...]
Sent: Friday, November 19, 2004 4:02 PM
To: Firebird-Java@yahoogroups.com
Subject: Re: [Firebird-Java] Conversions by ResultSet.getter Methods
> I'm calling ResultSet.getByte() on a field defined as CHAR(1) andto
> I'm getting the exception:
>
> org.firebirdsql.jdbc.field.TypeConvertionException: Error converting
> byte. Yhttp://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/mapping.html#101
>
> According to
>
> 3836 drivers may support this mapping. Is it Jaybird's intention toJayBird supports this table already (and even more). For your case it is
> support the entire table?
defined as:
public byte getByte() throws SQLException {
if (rs.row[numCol]==null) return BYTE_NULL_VALUE;
try {
return Byte.parseByte(getString().trim());
} catch (NumberFormatException nfex) {
throw (SQLException) createException(
BYTE_CONVERSION_ERROR+"
"+getString().trim()).fillInStackTrace();
}
}
However, if you have a CHAR(1) column containing "Y" as a value,
converting
it to a byte seems problematic. :) Can you suggest what should be the
result
of this conversion?
Roman
Yahoo! Groups Links