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 JConnect 5.5 & CLOB
Date Fri, 24 Mar 2006 19:53:44 GMT

<br><font size=2 face="sans-serif">Looking at the JConnect does:</font>
<br><font size=2 face="sans-serif">Warning! The TextPointer class has been
deprecated; that is, it is no longer recommended and may cease to exist
in a future version of jConnect.</font>
<br><font size=2 face="sans-serif">If your data server is Adaptive Server
version 12.5 or later or Adaptive Server Anywhere version 6.0 or later,
use the standard JDBC form to send image data:</font>
<br><font size=2 face="sans-serif">PreparedStatement.setBinaryStream(int
paramIndex,&nbsp;&nbsp;InputStream image)</font>
<br>
<br>
<br><font size=2 face="sans-serif">Seems to me that you could use an InputStream
to read and write the data and define within iBatis a customer row handler
to accommodate your needs.</font>
<br>
<br><font size=2 face="sans-serif"><br>
Chris Mathrusse<br>
christopher.mathrusse@sybase.com<br>
Sybase, Inc<br>
One Sybase Drive<br>
Dublin, CA 94568<br>
(925) 236-5553</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>&quot;Balaji&quot;
&lt;balaji@objectec.com&gt;</b>
</font>
<p><font size=1 face="sans-serif">03/24/2006 11:33 AM</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
user-java@ibatis.apache.org</font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td valign=top><font size=1 face="sans-serif">&lt;user-java@ibatis.apache.org&gt;</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">Re: Sybase JConnect 5.5 &amp;
CLOB</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2 face="Arial">Chris,</font>
<br><font size=3>&nbsp;</font>
<br><font size=2 face="Arial">Based on the Info on jconnect at this link
</font><a href="http://www.sybase.com/detail?id=1009774"><font size=2 color=blue
face="Arial"><u>http://www.sybase.com/detail?id=1009774</u></font></a><font
size=2 face="Arial">
&nbsp; under &nbsp;</font><font size=2 color=#333366 face="Arial">JDBC
2.0 Standard Methods Implementation topic getClob, getBlob etc have not
been implemented.</font>
<br><font size=3>&nbsp;</font>
<br><font size=2 color=#333366 face="Arial">What is the alternate datatype
in Sybase 12.0, other than Text datatype that could used to hold large
amount of text?</font>
<br><font size=3>&nbsp;</font>
<br><font size=2 color=#333366 face="Arial">here is a link to discussion
on the same subject on sybase.public.Jconnect.</font>
<br><a href="http://groups.google.com/group/sybase.public.jconnect/browse_thread/thread/5a7853514d297d86/9712446c173217f5?hl=en#9712446c173217f5"><font
size=2 color=blue face="Arial"><u>http://groups.google.com/group/sybase.public.jconnect/browse_thread/thread/5a7853514d297d86/9712446c173217f5?hl=en#9712446c173217f5</u></font></a>
<br><font size=3>&nbsp;</font>
<br><font size=2 color=#333366 face="Arial">Balaji</font>
<br><font size=3>----- Original Message ----- </font>
<br><font size=3><b>From:</b> </font><a href=mailto:Christopher.Mathrusse@sybase.com><font
size=3 color=blue><u>Christopher.Mathrusse@sybase.com</u></font></a><font
size=3>
</font>
<br><font size=3><b>To:</b> </font><a href="mailto:user-java@ibatis.apache.org"><font
size=3 color=blue><u>user-java@ibatis.apache.org</u></font></a><font
size=3>
</font>
<br><font size=3><b>Sent:</b> Friday, March 24, 2006 12:54 PM</font>
<br><font size=3><b>Subject:</b> Re: Sybase JConnect 5.5 &amp;
CLOB</font>
<br>
<br><font size=2 face="sans-serif"><br>
I know for a fact that when working with Oracle 9i I ran into problems
when trying to use CLOB for storing my XML documents. Because of that I
decided to use LONG RAW as the datatype on the table. I would stream the
results out of the table into a byte[]. &nbsp;This also allowed me to specify
the encoding for the field and prevented any loss of data. </font><font size=3><br>
</font><font size=2 face="sans-serif"><br>
I don't know if you have the ability to change the datatype but you may
want to consider it an option. You also may want to upgrade you JConnect
driver to version 6.0 as well as run the update for the metadata. &nbsp;This
will ensure that you have the latest code that addresses many issues.</font><font
size=3>
<br>
</font><font size=2 face="sans-serif"><br>
Other than that you may want to post a message pertaining to this on the
sybase.public.jconnect newsgroup to see if there is anyone that may have
experience with this. <br>
<br>
Chris Mathrusse<br>
christopher.mathrusse@sybase.com<br>
Sybase, Inc<br>
One Sybase Drive<br>
Dublin, CA 94568<br>
(925) 236-5553</font><font size=3> <br>
<br>
</font>
<table width=100%>
<tr valign=top>
<td width=47%><font size=1 face="sans-serif"><b>&quot;Balaji&quot;
&lt;balaji@objectec.com&gt;</b>
</font>
<p><font size=1 face="sans-serif">03/24/2006 10:35 AM</font><font size=3>
</font>
<br>
<table border=4 width=100%>
<tr valign=top>
<td width=100% bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
user-java@ibatis.apache.org</font></div></table>
<p>
<td width=52%>
<br>
<table width=100%>
<tr>
<td width=19%>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td width=80% valign=top><font size=1 face="sans-serif">&lt;user-java@ibatis.apache.org&gt;</font><font
size=3>
</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">Re: Sybase JConnect 5.5 &amp;
CLOB</font></table>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=49%>
<td width=50%></table>
<br></table>
<br><font size=3><br>
<br>
<br>
 &nbsp;</font><font size=2 face="Arial"><br>
I looked at an Oracle example </font><a href="http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do+I+use+a+BLOB+or+CLOB"><font
size=2 color=blue face="Arial"><u>http://opensource2.atlassian.com/confluence/oss/display/IBATIS/How+do+I+use+a+BLOB+or+CLOB</u></font></a><font
size=3>
<br>
 &nbsp;</font><font size=2 face="Arial"><br>
Looks like it is not supported and does not work if using Jconnect/Sybase</font><font
size=3>
<br>
 &nbsp;</font><font size=2 face="Arial"><br>
Does anyone have a working example(s) for sybase&amp;Jconnect reading/writing
Text datatype fields?</font><font size=3> </font><font size=2 face="Arial"><br>
Also is sybase Text datatype mapping to CLOB JDBCType is correct or not?</font><font
size=3>
<br>
 &nbsp;</font><font size=2 face="Arial"><br>
Thanks,</font><font size=3> <br>
 &nbsp;</font><font size=2 face="Arial"><br>
Balaji</font><font size=3> <br>
----- Original Message ----- <b><br>
From:</b> </font><a href=mailto:Christopher.Mathrusse@sybase.com><font
size=3 color=blue><u>Christopher.Mathrusse@sybase.com</u></font></a><font
size=3>
<b><br>
To:</b> </font><a href="mailto:user-java@ibatis.apache.org"><font size=3
color=blue><u>user-java@ibatis.apache.org</u></font></a><font
size=3>
<b><br>
Sent:</b> Wednesday, March 22, 2006 4:50 PM <b><br>
Subject:</b> Re: Sybase JConnect 5.5 &amp; CLOB <br>
</font><font size=2 face="sans-serif"><br>
<br>
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. </font><font size=2><tt><i><br>
<br>
iBATIS can fetch the BLOB as a stream of bytes. One way of doing what you
<br>
want is to create get/setters using byte[] that store/read to/from a private
<br>
String field, ie:<br>
<br>
public class MyBean implements Serializable{<br>
<br>
private String myString;<br>
<br>
public void setStringAsByteArray(byte[] b) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myString = String(b);<br>
}<br>
public byte[] getStringAsByteArray() {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return myString.getBytes();<br>
}<br>
<br>
public void setMyString(String s) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myString = s;<br>
}<br>
public String getMyString() {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return myString;<br>
}<br>
}<br>
<br>
and your result map:<br>
<br>
&lt;resultMap class=&quot;MyBean&quot; id=&quot;MyBeanResultMap&quot;&gt;<br>
&lt;result column=&quot;BLOB_COLUMN&quot; property=&quot;stringAsByteArray&quot;
jdbcType=&quot;BLOB&quot;/&gt;<br>
&lt;/resultMap&gt;<br>
<br>
That way you also have the chance to set the appropriate encoding to<br>
your string.</i></tt></font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
<br>
<br>
Chris Mathrusse<br>
christopher.mathrusse@sybase.com<br>
Sybase, Inc<br>
One Sybase Drive<br>
Dublin, CA 94568<br>
(925) 236-5553</font><font size=3> <br>
</font>
<table width=100%>
<tr valign=top>
<td width=47%><font size=1 face="sans-serif"><b>&quot;Balaji&quot;
&lt;balaji@objectec.com&gt;</b>
</font>
<p><font size=1 face="sans-serif">03/22/2006 02:41 PM</font><font size=3>
</font>
<br>
<table border=4 width=100%>
<tr valign=top>
<td width=100% bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
user-java@ibatis.apache.org</font></div></table>
<br>
<td width=52%>
<br>
<table width=100%>
<tr>
<td width=19%>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td width=80% valign=top><font size=1 face="sans-serif">&lt;user-java@ibatis.apache.org&gt;</font><font
size=3>
</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">Re: Sybase JConnect 5.5 &amp;
CLOB</font></table>
<br><font size=3><br>
</font>
<br>
<table width=100%>
<tr valign=top>
<td width=49%>
<td width=50%></table>
<br></table>
<br><font size=3><br>
<br>
</font><font size=2 face="Arial"><br>
<br>
Chris,</font><font size=3> <br>
 </font><font size=2 face="Arial"><br>
now i am getting </font><font size=2 color=blue face="Arial"><br>
Cause: java.sql.SQLException: JZ0TE: Attempted conversion between an illegal
pair of types. Valid database datatypes are: 'varbinay, long binary, binary,
image</font><font size=3> <br>
 </font><font size=2 face="Arial"><br>
Where should i be changing the datatype in POJO or resultMap? </font><font size=3><br>
 </font><font size=2 face="Arial"><br>
here is the code (msg field is defined as Text datatype in db). &nbsp;</font><font
size=3>
</font><font size=2 face="Arial"><br>
public class Email &nbsp;{ &nbsp; <br>
 private String from_addr;<br>
 private String to_addr;<br>
 private String subject;</font><font size=3> </font><font size=2 face="Arial"><br>
 &nbsp;</font><font size=2 color=#3f7f5f face="Arial">//private String
msg;</font><font size=2 face="Arial"><br>
 private byte[] msg;<br>
 <br>
public byte[] getMsg() {<br>
return msg;<br>
}<br>
<br>
public void setMsg(byte[] bs) {<br>
msg = bs;<br>
}</font><font size=3> </font><font size=2 face="Arial"><br>
----------------------------------------------------------------------------------------------</font><font
size=3>
</font><font size=2 face="Arial"><br>
&lt;resultMap class=&quot;Email&quot; id=&quot;EmailResult&quot;&gt;<br>
 &nbsp; &nbsp; &nbsp;&lt;result column=&quot;from_addr&quot; property=&quot;from_addr&quot;
/&gt;<br>
 &nbsp; &nbsp; &nbsp;&lt;result column=&quot;to_addr&quot; property=&quot;to_addr&quot;
/&gt;<br>
 &nbsp; &nbsp; &nbsp;&lt;result column=&quot;subject&quot; property=&quot;subject&quot;
/&gt;<br>
 &nbsp; &nbsp; &nbsp;&lt;result column=&quot;msg&quot; property=&quot;msg&quot;
jdbcType=&quot;CLOB&quot; /&gt;<br>
&lt;/resultMap&gt;</font><font size=3> <br>
 </font><font size=2 face="Arial"><br>
&lt;select id=&quot;getEmailById&quot; parameterClass=&quot;int&quot;
resultMap=&quot;EmailResult&quot;&gt;<br>
 &nbsp; &nbsp; &nbsp;SELECT &nbsp;from_addr, to_addr, subject, msg<br>
 &nbsp; &nbsp; &nbsp;FROM &nbsp; &nbsp;email_store<br>
 &nbsp; &nbsp; &nbsp;WHERE &nbsp; id_email = #VALUE#<br>
&lt;/select&gt;</font><font size=3> </font><font size=2 face="Arial"><br>
------------------------------------------------------------------------------------------------------</font><font
size=3>
<br>
 </font><font size=2 face="Arial"><br>
Thanks</font><font size=3> <br>
 </font><font size=2 face="Arial"><br>
Balaji</font><font size=3> <br>
----- Original Message ----- <b><br>
From:</b> </font><a href=mailto:Christopher.Mathrusse@sybase.com><font
size=3 color=blue><u>Christopher.Mathrusse@sybase.com</u></font></a><font
size=3>
<b><br>
To:</b> </font><a href="mailto:user-java@ibatis.apache.org"><font size=3
color=blue><u>user-java@ibatis.apache.org</u></font></a><font
size=3>
<b><br>
Sent:</b> Wednesday, March 22, 2006 4:18 PM <b><br>
Subject:</b> Re: Sybase JConnect 5.5 &amp; CLOB </font><font size=2 face="sans-serif"><br>
<br>
<br>
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.</font><font size=3> </font><font size=2
face="sans-serif"><br>
<br>
Chris Mathrusse</font><font size=3 color=blue><u><br>
</u></font><a href=mailto:christopher.mathrusse@sybase.com><font size=2
color=blue face="sans-serif"><u>christopher.mathrusse@sybase.com</u></font></a><font
size=2 face="sans-serif"><br>
Sybase, Inc<br>
One Sybase Drive<br>
Dublin, CA 94568<br>
(925) 236-5553</font><font size=3> </font>
<table width=100%>
<tr valign=top>
<td width=48%><font size=1 face="sans-serif"><b>&quot;Balaji&quot;
&lt;</b></font><a href=mailto:balaji@objectec.com><font size=1 color=blue
face="sans-serif"><b><u>balaji@objectec.com</u></b></font></a><font
size=1 face="sans-serif"><b>&gt;</b>
</font>
<p><font size=1 face="sans-serif">03/22/2006 02:15 PM</font><font size=3>
</font>
<br>
<table border=4 width=100%>
<tr valign=top>
<td width=100% bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to</font><font
size=3 color=blue><u><br>
</u></font><a href="mailto:user-java@ibatis.apache.org"><font size=1
color=blue face="sans-serif"><u>user-java@ibatis.apache.org</u></font></a></div></table>
<p>
<td width=51%>
<br>
<table width=100%>
<tr>
<td width=20%>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td width=79% valign=top><font size=1 face="sans-serif">&lt;user-java@ibatis.apache.org&gt;</font><font
size=3>
</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">Sybase JConnect 5.5 &amp;
CLOB</font></table>
<br><font size=3><br>
<br>
</font>
<br>
<table width=100%>
<tr valign=top>
<td width=49%>
<td width=50%></table>
<br></table>
<br><font size=3><br>
<br>
</font><font size=2><tt><br>
<br>
<br>
When i try to read a 'TEXT' datatype field from Sybase 12.0 database &amp;<br>
JConnect 5.5,<br>
- datatype in POJO is String &nbsp;(also tried java.sql.Clob)<br>
- jdbcType in resultMap is 'CLOB'<br>
<br>
i get the following error message shown below. &nbsp;Looks like getClob(string)<br>
is not implemented in Jconnect yet.<br>
<br>
Does anyone know how to get this to work, any workaround?<br>
<br>
Thanks<br>
Balaji<br>
<br>
/***************************************************************************<br>
*********************/<br>
 &nbsp; &nbsp; ERROR MESSAGE<br>
/***************************************************************************<br>
*********************/<br>
Caused by:<br>
java.lang.UnsupportedOperationException: The method<br>
com.sybase.jdbc2.jdbc.SybResultSet.getClob(String) is not supported and<br>
should not be called.<br>
at<br>
com.sybase.jdbc2.jdbc.ErrorMessage.raiseRuntimeException(ErrorMessage.java:7<br>
63)<br>
at com.sybase.jdbc2.utils.Debug.notSupported(Debug.java:366)<br>
at com.sybase.jdbc2.jdbc.SybResultSet.getClob(SybResultSet.java:1371)<br>
at<br>
com.ibatis.sqlmap.engine.type.ResultGetterImpl.getClob(ResultGetterImpl.java<br>
:108)<br>
at<br>
com.ibatis.sqlmap.engine.type.ClobTypeHandlerCallback.getResult(ClobTypeHand<br>
lerCallback.java:28)<br>
at<br>
com.ibatis.sqlmap.engine.type.CustomTypeHandler.getResult(CustomTypeHandler.<br>
java:52)<br>
at<br>
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getPrimitiveResultMap<br>
pingValue(BasicResultMap.java:552)<br>
at<br>
com.ibatis.sqlmap.engine.mapping.result.BasicResultMap.getResults(BasicResul<br>
tMap.java:311)<br>
at<br>
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor.jav<br>
a:390)<br>
at<br>
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java<br>
:184)<br>
at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(<br>
GeneralStatement.java:205)<br>
at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWith<br>
Callback(GeneralStatement.java:173)<br>
at<br>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForO<br>
bject(GeneralStatement.java:104)<br>
at<br>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx<br>
ecutorDelegate.java:561)<br>
at<br>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapEx<br>
ecutorDelegate.java:536)<br>
at<br>
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSession<br>
Impl.java:93)<br>
at<br>
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientIm<br>
pl.java:70)<br>
<br>
<br>
----- Original Message ----- <br>
From: &quot;Nathan Maves&quot; &lt;Nathan.Maves@Sun.COM&gt;<br>
To: &lt;user-java@ibatis.apache.org&gt;<br>
Sent: Tuesday, March 21, 2006 5:51 PM<br>
Subject: Re: multiple setters<br>
<br>
<br>
&gt; Ahhh yeah... &nbsp;not good don't have them. &nbsp;:)<br>
&gt;<br>
&gt; They are against the java bean specification.<br>
&gt;<br>
&gt; Nathan<br>
&gt; On Mar 21, 2006, at 4:38 PM, Ben Munat wrote:<br>
&gt;<br>
&gt; &gt; Hey All... I seem to remember someone talking recently about<br>
&gt; &gt; difficulties with a property set by ibatis having multiple setters.<br>
&gt; &gt; Does this ring a bell?<br>
&gt; &gt;<br>
&gt; &gt; b<br>
&gt;<br>
&gt;<br>
&gt;</tt></font><font size=3><br>
<br>
<br>
</font>
<br>

Mime
View raw message