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 <[email protected]>
01/16/2009 02:45 PM
Please respond to
[email protected]
To
[email protected]
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