ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick <ric...@gmail.com>
Subject Re: Sybase issue... TEXT column when null insert/updates fail, but when defined as VARCHAR nulls work?
Date Sat, 17 Jan 2009 14:59:07 GMT
Thanks for this Christopher.

Interestingly, I tried out the jtds driver and it allowed the null
inserts on TEXT datatype. . (Then again jtds had the problem with the
DATE field, putting things in off a few seconds unless I did
convert(DATETIME, bd.broadcastDate) ). Just curious, do you know if
they have plans to fix this in the jconnect driver? Seems like a bug?

I'll probably use the handler you provided and change my TEXT types to
LONGVARCHAR. Thanks again, this was really helpful.


On Fri, Jan 16, 2009 at 5:56 PM,  <Christopher.Mathrusse@sybase.com> wrote:
>
> 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
> below:
>
> public class ClobTypeHandlerCallback extends
>                 StreamTypeHandlerCallback {
>
>         public Object getResult(ResultGetter getter) throws SQLException {
>                 java.sql.ResultSet rs = getter.getResultSet();
>                 java.io.OutputStream os =
>  getAsOutputStream(rs.getAsciiStream(getter.getColumnName()));
>
>                 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
> user-java@ibatis.apache.org
> To
> ibatis-user-java@incubator.apache.org
> cc
> Subject
> 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?
>
>
>
> --
> Rick
>
>
>



-- 
Rick

Mime
View raw message