"The server was expecting token 32 but got the token 33"

1,911 views
Skip to first unread message

Bill

unread,
Aug 20, 2010, 10:46:35 AM8/20/10
to mybatis-user
I am running into a problem with a simple database row insert into
Sybase.

I could see others running into the same problem since we use the same
jconn3 driver.

I am using iBatis 2.3.4.726 (the last version of iBatis 2), Sybase
Thin jconn3 version 6.5 drivers, and JUnit 4 on Java 1.6.

The problem is that you can't insert into a table if there are more
than 2 text/varchar columns defined in the table.

For instance if you have a table like this:

CREATE TABLE section(
id INTEGER IDENTITY PRIMARY KEY,
name text,
summary text,
description text
)

And you try the configuration above, you receive the following error:

com.sybase.jdbc3.jdbc.SybSQLException: A wrong datastream has been
sent to the server. The server was expecting token 32 but got the
token 33. This is an internal error.

at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
at com.sybase.jdbc3.tds.Tds.new(Unknown Source)
at com.sybase.jdbc3.tds.Tds.doCommand(Unknown Source)
at com.sybase.jdbc3.tds.Tds.endTransaction(Unknown Source)
at com.sybase.jdbc3.jdbc.SybConnection.rollback(Unknown Source)
...
at com.ibatis.common.jdbc.SimpleDataSource
$SimplePooledConnection.invoke(SimpleDataSource.java:958)
...
at
com.ibatis.common.jdbc.logging.ConnectionLogProxy.invoke(ConnectionLogProxy.java:
68)
...
at
com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransaction.rollback(JdbcTransaction.java:
72)
at
com.ibatis.sqlmap.engine.transaction.TransactionManager.end(TransactionManager.java:
87)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.endTransaction(SqlMapExecutorDelegate.java:
734)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.endTransaction(SqlMapSessionImpl.java:
176)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.endTransaction(SqlMapClientImpl.java:
153)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.autoEndTransaction(SqlMapExecutorDelegate.java:
835)
at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:
410)
at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:
82)
at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:
58)
at com.xxxxxxxxxxx.dao.SectionDAO.createSection(SectionDAO.java:75)
at com.xxxxxxxxxxx.model.SectionTest.testContext(SectionTest.java:34)
...
at
org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:
160)

Now change the table definition to leave out the description field to
this:

CREATE TABLE section(
id INTEGER IDENTITY PRIMARY KEY,
name text,
summary text
)

Then the table insert happens.

There is not much on Google for the "The server was expecting token 32
but got the token 33" exception.

http://www.talendforge.org/bugs/view.php?id=13087&nbn=2
http://comments.gmane.org/gmane.comp.java.ibatisdb.user/39

This post (updated today) in particular uses the jconn3 driver with
Hibernate/Spring/JBoss:

http://community.jboss.org/message/557138

It mentions switching to jTDS driver for Sybase which is not an option
for me.

I see a bug was opened up on it on the old iBatis' Apache Support
site:

http://osdir.com/ml/db.ibatis.devel/2006-04/msg00036.html

But the bug was closed prematurely by Larry Meadors with iBatis
because they moved to Google Groups myBatis.

Larry Meadors

unread,
Aug 20, 2010, 11:06:39 AM8/20/10
to mybati...@googlegroups.com
On Fri, Aug 20, 2010 at 8:46 AM, Bill <bill.c...@gmail.com> wrote:
> But the bug was closed prematurely by Larry Meadors with iBatis
> because they moved to Google Groups myBatis.

Heh, that was in April of 2006 (4 years before we moved) and I closed
it because it was a support request that should have been on the
mailing list, not a bug. :)

In any case, have you tried this with straight up jdbc? If it works
with jdbc, we should be able to make it work with ibatis.

Larry

Clinton Begin

unread,
Aug 20, 2010, 11:30:12 AM8/20/10
to mybati...@googlegroups.com
iBATIS 2.x is about six years old.  Such a fundamental problem probably would have been found far earlier than this. It's not impossible, just unlikely.

My advice to validate the problem is to try a few things:

* First try a different driver.  Like jTDS, just to see if the problem persists.  I wish I could say that all drivers are equal, but we all know they're not.  :-)

* Second, try specifying the jdbcType for the parameters.  VARCHAR, CLOB, etc... This will change how mybatis sets the parameter.

* Third, debug it and see which typehandler is being used, to make sure it's using the right one. 

* Fourth, try what Larry said. Write it in JDBC to see if you can reproduce the problem (try with clob and setString).

* Finally, if you can create a unit test that demonstrates the problem, and or a patch, it will speed up resolution of the issue.

Cheers,
Clinton

On Fri, Aug 20, 2010 at 8:46 AM, Bill <bill.c...@gmail.com> wrote:

Bill

unread,
Aug 20, 2010, 2:53:30 PM8/20/10
to mybatis-user
Clinton and Larry,

Thank you very much for your replies.

I will definitely try a different driver.

I ran into this again today with a much simpler example. Just a basic
delete statement. Now I have to be doing something wrong because this
is too simple not to work.

I took the fourth suggestion and wrote it in regular JDBC and it
worked fine.

Here is what I found. In my sql-map file I had:

...
<delete id="deleteSection"
parameterClass="com.xxxxxx.model.Section">
DELETE section WHERE id = #value#
</delete>
...

I debugged and saw that the parameter was null. The parameter was
null because my class has no 'value' attribute. It was supposed to be
'id', so I changed it to this:

...
<delete id="deleteSection"
parameterClass="com.xxxxxx.model.Section">
DELETE section WHERE id = #id#
</delete>
...

I am a bit embarrassed but at least I found it. The exception the
Sybase driver throws completely throws you off. It looks more serious
than it really is. I am not sure what the reason was behind the first
problem I originally posted about. I just know that "the server was
expecting token 32 but got the token 33" is a something went terribly
wrong exception which means a simple fix.

Thanks!

Larry Meadors

unread,
Aug 20, 2010, 3:17:04 PM8/20/10
to mybati...@googlegroups.com
Hehehe, funny.

I won't tell you how many hours I spent on a <select/> without a
result map or result class defined that was giving me a list with the
right number of values...that were all null. :)

Larry

Bryan Shannon

unread,
Aug 27, 2010, 7:15:40 AM8/27/10
to mybati...@googlegroups.com, mybati...@googlegroups.com
This is Sybase specific. If you pass a null as a parameter it needs to know it's type. Use the #parm:jdbctype# for the nullable args. Drove us nuts here too, but it's sybases funky exception that throws you off.
-Bryan
Reply all
Reply to author
Forward
0 new messages