You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by WhyDontYouSlide <wh...@gmail.com> on 2008/06/06 11:50:17 UTC
JDBC Type 0 not yet supported
Hey all,
I would like to share you guys this problem im getting constantly by using
Ibatis via jdbc to do queries on DB2...
Let's say we have written a simple query like this
SELECT PCT_SCO_MAX,
FROM $schema$.FLES_PERC_SCO
WHERE COD_COMPANY = #codCompany#
AND COD_SELLER = #codSeller#
the JDBC drivers via Ibatis framework CANNOT map a EMPTY STRING value into
"codSeller"
infact it maps "null" as you can see in the log:
DEBUG [java.sql.PreparedStatement]--<{pstm-105524} Parameters: [112, null]>
but this way makes your query NOT fetch any results...
So i've rounded the problem witha /dynamic TAG but this solution is not
stylish ;-)
<dynamic>
<isNotEmpty prepend="AND" property="codSeller">
COD_SELLER = #codTipoUnita#
</isNotEmpty>
<isEmpty prepend="AND" property="codSeller">
COD_SELLER = ' '
</isEmpty>
</dynamic>
someone got a better idea???
thx
WDYS
--
View this message in context: http://www.nabble.com/JDBC-Type-0-not-yet-supported-tp17688418p17688418.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: JDBC Type 0 not yet supported
Posted by WhyDontYouSlide <wh...@gmail.com>.
yea with a typeHandler like this i cen get through the problem
public Object getResult(CallableStatement cs, int columnIndex)
throws SQLException {
Object s = cs.getString(columnIndex);
if(cs.wasNull())
return Constants.EMPTY_STRING;
else
return ((String)s).trim();
}
public Object getResult(ResultSet rs, int columnInt) throws SQLException {
Object s = rs.getString(columnInt);
if(rs.wasNull())
return Constants.EMPTY_STRING;
else
return ((String)s).trim();
}
public Object getResult(ResultSet rs, String columnName) throws
SQLException {
Object s = rs.getString(columnName);
if(rs.wasNull())
return Constants.EMPTY_STRING;
else
return ((String)s).trim();
}
public void setParameter(PreparedStatement ps, int i, Object parameter,
String jdbcType)
throws SQLException
{
if (parameter!=null && !parameter.equals(Constants.EMPTY_STRING))
ps.setString(i, (String)parameter);
else
ps.setString(i, Constants.EMPTY_STRING);
}
Thanks guys
WDYS
Gilles Bayon wrote:
>
> You can use a custom string type handler.
>
> --
> Cheers,
> Gilles
>
>
--
View this message in context: http://www.nabble.com/JDBC-Type-0-not-yet-supported-tp17688418p17690887.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: JDBC Type 0 not yet supported
Posted by Gilles Bayon <ib...@gmail.com>.
You can use a custom string type handler.
--
Cheers,
Gilles
Re: JDBC Type 0 not yet supported
Posted by Clinton Begin <cl...@gmail.com>.
I can assure you, it's not iBATIS doing that... iBATIS does not translate
any values. So your JDBC driver is the problem here, and it appears you've
found a way for iBATIS to solve it. I've known other drivers to do the same
thing. I belive NULL and '' are equal in Sybase/SQL Server as well...
Clinton
On Fri, Jun 6, 2008 at 3:50 AM, WhyDontYouSlide <wh...@gmail.com>
wrote:
>
> Hey all,
>
> I would like to share you guys this problem im getting constantly by using
> Ibatis via jdbc to do queries on DB2...
>
> Let's say we have written a simple query like this
>
> SELECT PCT_SCO_MAX,
> FROM $schema$.FLES_PERC_SCO
> WHERE COD_COMPANY = #codCompany#
> AND COD_SELLER = #codSeller#
>
> the JDBC drivers via Ibatis framework CANNOT map a EMPTY STRING value into
> "codSeller"
> infact it maps "null" as you can see in the log:
>
> DEBUG [java.sql.PreparedStatement]--<{pstm-105524} Parameters: [112, null]>
>
> but this way makes your query NOT fetch any results...
>
> So i've rounded the problem witha /dynamic TAG but this solution is not
> stylish ;-)
>
> <dynamic>
> <isNotEmpty prepend="AND" property="codSeller">
> COD_SELLER = #codTipoUnita#
> </isNotEmpty>
> <isEmpty prepend="AND" property="codSeller">
> COD_SELLER = ' '
> </isEmpty>
> </dynamic>
>
> someone got a better idea???
>
> thx
>
> WDYS
> --
> View this message in context:
> http://www.nabble.com/JDBC-Type-0-not-yet-supported-tp17688418p17688418.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>