How do I retrieve byte[] from sybases ASA?  (I have not tried write to it yet.  
May need to write to it too.)

I am using Sybase ASA 9, jconnect 5.5, EJB3 preview 5 in jboss 4.0.2.  When I 
leave the sybase type-mapping in standardjbosscmp-jdbc.xml alone (ie, the byte, 
short mapping are commented out), and in my entity bean, I have

                @Lob(fetch = FetchType.EAGER)
        public byte[] getMasterMac() {
            return masterMac;
        }

as did in examples in the EJB3 preview 5, then, I got error:

java.lang.UnsupportedOperationException: The method 
com.sybase.jdbc2.jdbc.SybResultSet.getBlob(String) is not supported and should 
not be called.


Sure enough, I checked jconnect document, it clearly indicated the getBlob(), 
getClob() methods are not supported.


My next choice is to manually change the byte type mapping.  Here are the 3 
type mappings that I tried:

(1) Uncomment out the original comments:


         
            <java-type>java.lang.Byte</java-type>
            <jdbc-type>TINYINT</jdbc-type>
            <sql-type>TINYINT</sql-type>
         


(2)
         
            <java-type>java.lang.Byte</java-type>
            <jdbc-type>VARBINARY</jdbc-type>
            <sql-type>VARBINARY</sql-type>
         
         
            <java-type>byte[]</java-type>
            <jdbc-type>VARBINARY</jdbc-type>
            <sql-type>VARBINARY</sql-type>
         

(3) 
         
            <java-type>java.lang.Byte</java-type>
            <jdbc-type>VARBINARY</jdbc-type>
            <sql-type>VARBINARY</sql-type>
         
         
            <java-type>byte[]</java-type>
            <jdbc-type>VARBINARY(255)</jdbc-type>
            <sql-type>VARBINARY(255)</sql-type>
         


I also tried to use BINARY instead of VARBINARY, none of them work.  I always 
got error:

2005-06-11 00:31:40,359 DEBUG [Loader]: result set row: 0
2005-06-11 00:31:40,359 DEBUG [LongType]: returning '1' as column: id
2005-06-11 00:31:40,359 DEBUG [Loader]: result row: 
EntityKey[com.myapp.beans.models.Node#1]
2005-06-11 00:31:40,359 DEBUG [Loader]: Initializing object from ResultSet: 
[com.myapp.beans.models.Node#1]
2005-06-11 00:31:40,359 DEBUG [BasicEntityPersister]: Hydrating entity: 
[com.myapp.beans.models.Node#1]
2005-06-11 00:31:40,359 DEBUG [IntegerType]: returning '1' as column: state1_
2005-06-11 00:31:40,359 DEBUG [StringType]: returning 'South' as column: 
domainName1_
2005-06-11 00:31:40,375 DEBUG [IntegerType]: returning '100' as column: 
helloTim9_1_
2005-06-11 00:31:40,375 DEBUG [AbstractBatcher]: about to close ResultSet (open 
ResultSets: 1, globally: 1)
2005-06-11 00:31:40,390 DEBUG [AbstractBatcher]: about to close 
PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-06-11 00:31:40,390 DEBUG [AbstractBatcher]: closing statement
2005-06-11 00:31:40,421 DEBUG [JDBCExceptionReporter]: could not execute query 
[select node0_.id as id, node0_.state as state1_, node0_.domainName as 
domainName1_, node0_.helloTimerInterval as helloTim9_1_, node0_.masterMac as 
masterMac1_ from Node node0_]
java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0EM: 
End of data.
        at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:485)
        at com.sybase.jdbc2.tds.Tds.handleIOE(Tds.java:2966)
        at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2029)
        at com.sybase.jdbc2.tds.TdsResultSet.nextResult(TdsResultSet.java:512)
        at com.sybase.jdbc2.tds.TdsResultSet.next(TdsResultSet.java:298)
        at com.sybase.jdbc2.tds.TdsResultSet.close(TdsResultSet.java:394)
        at com.sybase.jdbc2.jdbc.SybResultSet.markDead(SybResultSet.java:1509)
        at com.sybase.jdbc2.jdbc.SybResultSet.close(SybResultSet.java:1567)
        at com.sybase.jdbc2.jdbc.SybResultSet.close(SybResultSet.java:182)
        at 
org.jboss.resource.adapter.jdbc.WrappedResultSet.internalClose(WrappedResultSet.java:808)
        at 
org.jboss.resource.adapter.jdbc.WrappedResultSet.close(WrappedResultSet.java:133)
        at 
org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:137)
        at org.hibernate.loader.Loader.doQuery(Loader.java:408)
        at 
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
        at org.hibernate.loader.Loader.doList(Loader.java:1515)
        at org.hibernate.loader.Loader.list(Loader.java:1498)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
        at 
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:266)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:791)
        at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
        at org.jboss.ejb3.entity.QueryImpl.getResultList(QueryImpl.java:58)



>From the trace you can see that the retrieving did not get masterMac1_, the 
>byte array (defined as binary(6) for the column type) column

 
How should I solve this problem?  Thanks in advance.




View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3881172#3881172

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3881172


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to