ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject Re: Sybase issue... TEXT column when null insert/updates fail, but when defined as VARCHAR nulls work?
Date Fri, 16 Jan 2009 22:56:41 GMT
This is a JConnect Driver issue. It doesn't like it when you attempt to 
set a NULL for a TEXT field. This is something that I have run into many 
times. One easy solution is rather than assigning NULL try assigning an 
empty string. This gets around the issue in the driver.

As a side note, you may want to perform some tests with this type of 
definition in iBatis. My experience has show that a TEXT field that is 
defined as VARCHAR will usually get truncated after a certain number of 
characters. ( I can't remember the size) 

To work around both these issues I defined a custom type handler. Code 

public class ClobTypeHandlerCallback extends
                StreamTypeHandlerCallback {

        public Object getResult(ResultGetter getter) throws SQLException {
                java.sql.ResultSet rs = getter.getResultSet();
                java.io.OutputStream os = 

                return os != null ? os.toString() : null;

        public void setParameter(ParameterSetter setter, Object parameter)
                        throws SQLException {
                super.setAsciiStream(setter, parameter);

And register it as follows:
  <typeHandler javaType="java.lang.String" jdbcType="LONGVARCHAR"
    callback="com.....ClobTypeHandlerCallback" />

I hope this helps you.

Rick <rickcr@gmail.com> 
01/16/2009 02:45 PM
Please respond to


Sybase issue... TEXT column when null insert/updates fail, but when 
defined as VARCHAR nulls work?

I'm a bit curious about this. I'm using the jconnect driver( jconn3
version 6.) I have a column defined as:

datatype: 2005
type_name: TEXT
Column size: 2147483647
Buffer Length: 16

On retrievals TEXT works just fine, and on updates/inserts TEXT is
fine also IF the field is not null, but if the field is null, Sybase
complains when it's declared as a TEXT (or CLOB) (   #spec:TEXT#  ).
Yet if I change it to VARCHAR the null value is accepted and the
insert/update works.  Shouldn't TEXT jdbc type work for all phases of
the CRUD?


View raw message