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 Zsolt <zk...@intland.com> on 2006/10/09 14:12:49 UTC

iBATIS with the embedded Derby JDBC driver

Hi,

Our product uses the services of iBATIS and we are using MySQL for the 
database layer. We recently tried out the Derby database engine and we 
were mainly successful.

We have an issue though, which seems to be related to iBATIS. While 
things are under control with the networked Derby JDBC driver, the 
embedded Derby JDBC driver does not work and we systematically receive 
the following stack trace pattern:

 java.sql.SQLException: An attempt was made to get a data value of type 
'VARCHAR' from a data value of type '0'.
    at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(Ge
neralStatement.java:91)

Based on discussions with the Derby team, the problem seems to appear 
due to a misbehaving iBATIS call. More specifically, the 
java.sql.PreparedStatement.setNull(int parameterIndex, int sqlType)  
call seems to be always made with the sqlType argument being 0 instead 
of the type of the parameter.

We are using iBATIS 2.1.7.597. We did not dive into the iBATIS source 
code but instead thought to ask here. Is this a known issue?

Zsolt


Re: iBATIS with the embedded Derby JDBC driver

Posted by Jeff Butler <je...@gmail.com>.
It avoids another introspection (if the getter returns null, then iBATIS
would need to look up the getter type and then translate to a JDBC type).

There has been some talk about adding support for that kind of introspection
with nulls, but no one's signed up to do it - and I'm not sure it's worth
the (minor) performance hit.

Of course, if the DB2 drivers didn't choke on this, it would be even better
- but it's not just DB2 that has the issue.

Jeff Butler


On 10/10/06, Zsolt <zk...@intland.com> wrote:
>
>  Thank you Jeff,
>
>
>
> Why is that necessary if I pass (java.lang.Integer)null?
>
>
>
> Zsolt
>
>
>   ------------------------------
>
> *From:* Jeff Butler [mailto:jeffgbutler@gmail.com]
> *Sent:* Monday, October 09, 2006 4:34 PM
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: iBATIS with the embedded Derby JDBC driver
>
>
>
> If a column can be null, then you need to specify the JDBC type in the
> mapping.  For example:
>
>
>
> <insert ...>
>
>   insert into sometable (id, desc)
>
>   values(#id:INTEGER#, #desc:VARCHAR#)
>
> </insert>
>
>
> This is true for all the DB2-like databases.
>
>
>
> Jeff Butler
>
>
>
>
>
>
> On 10/9/06, *Zsolt* <zk...@intland.com> wrote:
>
> Hi,
>
> Our product uses the services of iBATIS and we are using MySQL for the
> database layer. We recently tried out the Derby database engine and we
> were mainly successful.
>
> We have an issue though, which seems to be related to iBATIS. While
> things are under control with the networked Derby JDBC driver, the
> embedded Derby JDBC driver does not work and we systematically receive
> the following stack trace pattern:
>
> java.sql.SQLException: An attempt was made to get a data value of type
> 'VARCHAR' from a data value of type '0'.
>    at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(Ge
> neralStatement.java:91)
>
> Based on discussions with the Derby team, the problem seems to appear
> due to a misbehaving iBATIS call. More specifically, the
> java.sql.PreparedStatement.setNull(int parameterIndex, int sqlType)
> call seems to be always made with the sqlType argument being 0 instead
> of the type of the parameter.
>
> We are using iBATIS 2.1.7.597. We did not dive into the iBATIS source
> code but instead thought to ask here. Is this a known issue?
>
> Zsolt
>
>
>

RE: iBATIS with the embedded Derby JDBC driver

Posted by Zsolt <zk...@intland.com>.
Thank you Jeff,

 

Why is that necessary if I pass (java.lang.Integer)null?

 

Zsolt

 

  _____  

From: Jeff Butler [mailto:jeffgbutler@gmail.com] 
Sent: Monday, October 09, 2006 4:34 PM
To: user-java@ibatis.apache.org
Subject: Re: iBATIS with the embedded Derby JDBC driver

 

If a column can be null, then you need to specify the JDBC type in the
mapping.  For example:

 

<insert ...>

  insert into sometable (id, desc)

  values(#id:INTEGER#, #desc:VARCHAR#)

</insert>
 

This is true for all the DB2-like databases.

 

Jeff Butler

 


 

On 10/9/06, Zsolt <zk...@intland.com> wrote: 

Hi,

Our product uses the services of iBATIS and we are using MySQL for the
database layer. We recently tried out the Derby database engine and we 
were mainly successful.

We have an issue though, which seems to be related to iBATIS. While
things are under control with the networked Derby JDBC driver, the
embedded Derby JDBC driver does not work and we systematically receive 
the following stack trace pattern:

java.sql.SQLException: An attempt was made to get a data value of type
'VARCHAR' from a data value of type '0'.
   at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate
(Ge
neralStatement.java:91)

Based on discussions with the Derby team, the problem seems to appear
due to a misbehaving iBATIS call. More specifically, the
java.sql.PreparedStatement.setNull(int parameterIndex, int sqlType) 
call seems to be always made with the sqlType argument being 0 instead
of the type of the parameter.

We are using iBATIS 2.1.7.597. We did not dive into the iBATIS source
code but instead thought to ask here. Is this a known issue? 

Zsolt

 


Re: iBATIS with the embedded Derby JDBC driver

Posted by Jeff Butler <je...@gmail.com>.
If a column can be null, then you need to specify the JDBC type in the
mapping.  For example:

<insert ...>
  insert into sometable (id, desc)
  values(#id:INTEGER#, #desc:VARCHAR#)
</insert>

This is true for all the DB2-like databases.

Jeff Butler



On 10/9/06, Zsolt <zk...@intland.com> wrote:
>
> Hi,
>
> Our product uses the services of iBATIS and we are using MySQL for the
> database layer. We recently tried out the Derby database engine and we
> were mainly successful.
>
> We have an issue though, which seems to be related to iBATIS. While
> things are under control with the networked Derby JDBC driver, the
> embedded Derby JDBC driver does not work and we systematically receive
> the following stack trace pattern:
>
> java.sql.SQLException: An attempt was made to get a data value of type
> 'VARCHAR' from a data value of type '0'.
>    at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate
> (Ge
> neralStatement.java:91)
>
> Based on discussions with the Derby team, the problem seems to appear
> due to a misbehaving iBATIS call. More specifically, the
> java.sql.PreparedStatement.setNull(int parameterIndex, int sqlType)
> call seems to be always made with the sqlType argument being 0 instead
> of the type of the parameter.
>
> We are using iBATIS 2.1.7.597. We did not dive into the iBATIS source
> code but instead thought to ask here. Is this a known issue?
>
> Zsolt
>
>