ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cyril <cyril_j...@yahoo.fr>
Subject Re : Re : Problem with multi result set
Date Tue, 19 Sep 2006 13:18:56 GMT
Hi again,

I have still the problem with iBatis 2.2.0 . 

My problem is with a stored procedure in Sybase returning multi result set. In the class com.ibatis.sqlmap.engine.execution.SqlExecutor
from Clinton, there is a call to getFirstResultSet which call moveToNextResultsIfPresent.

The program crashes (with the strange "SybSQLException: Incorrect syntax near the keyword
'from'.") when accessing for the 5th time stmt.getUpdateCount(), each previous call having
return "1", indicating there were more results to "getFirstResultSet".

I think it may be a problem with the JDBC driver, has anybody been confronted to this problem?


Here is the code from SqlExecutor:

  private ResultSet getFirstResultSet(Statement stmt) throws SQLException {
    ResultSet rs = null;
    boolean hasMoreResults = true;
    while (hasMoreResults) {
      rs = stmt.getResultSet();
      if (rs != null) {        //** Cyril: Always null before the crash
      hasMoreResults = moveToNextResultsIfPresent(stmt);
    return rs;

  private boolean moveToNextResultsIfPresent(Statement stmt) throws SQLException {
    boolean moreResults;
    // This is the messed up JDBC approach for determining if there are more results
    moreResults = !(((moveToNextResultsSafely(stmt) == false) && (stmt.getUpdateCount()
== -1))); //** Cyril: The getUpdateCount crashes here, the 5th time
    return moreResults;

----- Message d'origine ----
De : Cyril <cyril_jade@yahoo.fr>
À : user-java@ibatis.apache.org
Envoyé le : Mardi, 19 Septembre 2006, 10h12mn 42s
Objet : Re : Problem when executing stored procedure "Incorrect syntax near the keyword"

It seems that this stored procedure has a multi-result set result. The version of iBatis we
are currently using doesn't work with such procedure, but I see the latest release supports
this functionnality.

Time to update our version of iBatis !


----- Message d'origine ----
De : Cyril <cyril_jade@yahoo.fr>
À : user-java@ibatis.apache.org
Envoyé le : Lundi, 18 Septembre 2006, 6h02mn 31s
Objet : Problem when executing stored procedure "Incorrect syntax near the keyword"


I'm migrating an application from an internal JDBC framework to iBatis. Currently, a lot of
the business work is done in stored procedure, so I just need to call the stored procedures
from DAO with iBatis.

Until now, I hadn't any major issue, but when calling a particular stored procedure, I was
stucked with an SQLException with my sqlMap.queryForList.  The exception is:

com.sybase.jdbc2.jdbc.SybSQLException: Incorrect syntax near the keyword 'from'.

(my data base is Sybase)

It doesn't look an iBatis problem, but when I call the same procedure with the same parameters
from JDBC  or from my SQL client, everything is ok.

My iBatis sql map file contains:

<resultMap id="deliveryDetailResult" class="com.calyon.ccc.ibatis.pojo.DeliveryUtilizationLineFromDatabase">
        <result property="id" column="Id"/>
        <result property="amount" column="Utilisation"/>
        <result property="keyName" column="KeyName"/>
        <result property="authorizationId" column="KeyValue"/>
        <result property="utilizationDate" column="Date"/>

<procedure id="getDetailedDeliveryUtilizations2" resultMap="deliveryDetailResult">
            {call CCCGetDeliveryUtilization("TODAY", "Profile", "Client", "1234567890", "All",

It's just a procedure call, there is no "from" in it. Since I can call the stored procedure
with these parameters from JDBC or SQL client, I assume there is also no problem in the stored
procedure (which contains "from").

My DAO looks like:
List result = null;
try {
      result = sqlMap.queryForList("getDetailedDeliveryUtilizations2", new ArrayList());
} catch (SQLException sqle) {
       LOGGER.error("SQLException " + sqle.getMessage(), sqle);

Since I traced with the debugger quite deep in iBatis, I can't understand the problem. It
should not come from iBatis, but does somebody have an idea?

Cyril Gambis

View raw message