|
Looks like it is not supported and does not work if
using Jconnect/Sybase
Does anyone have a working example(s) for
sybase&Jconnect reading/writing Text datatype fields?
Also is sybase Text datatype mapping to CLOB
JDBCType is correct or not?
Thanks,
Balaji
----- Original Message -----
Sent: Wednesday, March 22, 2006 4:50
PM
Subject: Re: Sybase JConnect 5.5 &
CLOB
I think your problem is that
you need to tell iBatis the column type that you are fetching. This is from a
previous email in the archive.
iBATIS can
fetch the BLOB as a stream of bytes. One way of doing what you want is to
create get/setters using byte[] that store/read to/from a private String
field, ie:
public class MyBean implements
Serializable{
private String myString;
public void
setStringAsByteArray(byte[] b) {
myString = String(b); } public byte[]
getStringAsByteArray() {
return myString.getBytes(); }
public void
setMyString(String s) {
myString = s; } public String getMyString()
{ return
myString; } }
and your result map:
<resultMap
class="MyBean" id="MyBeanResultMap"> <result
column="BLOB_COLUMN" property="stringAsByteArray"
jdbcType="BLOB"/> </resultMap>
That way you also have the
chance to set the appropriate encoding to your string.
Chris
Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase
Drive Dublin, CA 94568 (925) 236-5553
| "Balaji"
<[EMAIL PROTECTED]>
03/22/2006 02:41 PM
|
|
Chris, now i am getting Cause:
java.sql.SQLException: JZ0TE: Attempted conversion between an illegal pair of
types. Valid database datatypes are: 'varbinay, long binary, binary,
image Where should i be changing the datatype in POJO or
resultMap? here is the code (msg field is defined as Text datatype in
db). public class Email
{ private String from_addr; private String
to_addr; private String subject; //private
String msg; private byte[]
msg; public byte[] getMsg() { return
msg; } public void setMsg(byte[] bs) { msg =
bs; } ----------------------------------------------------------------------------------------------
<resultMap class="Email"
id="EmailResult"> <result
column="from_addr" property="from_addr" />
<result column="to_addr" property="to_addr" />
<result column="subject" property="subject" />
<result column="msg" property="msg" jdbcType="CLOB"
/> </resultMap> <select id="getEmailById" parameterClass="int"
resultMap="EmailResult"> SELECT
from_addr, to_addr, subject, msg FROM
email_store WHERE id_email =
#VALUE# </select> ------------------------------------------------------------------------------------------------------
Thanks
Balaji
----- Original Message ----- From: [EMAIL PROTECTED]
To: [email protected]
Sent: Wednesday, March 22, 2006 4:18 PM
Subject: Re: Sybase JConnect 5.5 & CLOB
You should be reading the CLOB out of
the database into a byte[] rather than a String. From there you can convert it
into a String and apply any encoding that might be necessary.
Chris
Mathrusse [EMAIL PROTECTED] Sybase, Inc One Sybase Drive Dublin, CA
94568 (925) 236-5553
When i try to read a 'TEXT'
datatype field from Sybase 12.0 database & JConnect 5.5, - datatype
in POJO is String (also tried java.sql.Clob) - jdbcType in resultMap
is 'CLOB'
i get the following error message shown below. Looks
like getClob(string) is not implemented in Jconnect yet.
Does anyone
know how to get this to work, any
workaround?
Thanks Balaji
/*************************************************************************** *********************/
ERROR
MESSAGE /*************************************************************************** *********************/ Caused
by: java.lang.UnsupportedOperationException: The
method com.sybase.jdbc2.jdbc.SybResultSet.getClob(String) is not supported
and should not be
called. at com.sybase.jdbc2.jdbc.ErrorMessage.raiseRuntimeException(ErrorMessage.java:7 63) at
com.sybase.jdbc2.utils.Debug.notSupported(Debug.java:366) at
com.sybase.jdbc2.jdbc.SybResultSet.getClob(SybResultSet.java:1371) at com.ibatis.sqlmap.engine.type.ResultGetterImpl.getClob(ResultGetterImpl.java :108) at com.ibatis.sqlmap.engine.type.ClobTypeHandlerCallback.getResult(ClobTypeHand lerCallback.java:28) at com.ibatis.sqlmap.engine.type.CustomTypeHandler.getResult(CustomTypeHandler. java:52) at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getPrimitiveResultMap pingValue(BasicResultMap.java:552) at com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResul tMap.java:311) at com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.jav a:390) at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java :184) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery( GeneralStatement.java:205) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWith Callback(GeneralStatement.java:173) at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForO bject(GeneralStatement.java:104) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx ecutorDelegate.java:561) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx ecutorDelegate.java:536) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSession Impl.java:93) at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientIm pl.java:70)
-----
Original Message ----- From: "Nathan Maves"
<[EMAIL PROTECTED]> To:
<[email protected]> Sent: Tuesday, March 21, 2006 5:51
PM Subject: Re: multiple setters
> Ahhh yeah... not
good don't have them. :) > > They are against the java bean
specification. > > Nathan > On Mar 21, 2006, at 4:38 PM, Ben
Munat wrote: > > > Hey All... I seem to remember someone
talking recently about > > difficulties with a property set by ibatis
having multiple setters. > > Does this ring a bell? >
> > > b > > >
|