pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: fengyun <fengyun@ceno.cn>
To: pgsql-jdbc@postgresql.org
Subject: '{ CALL put_umc_domain_attr (?, ?, ?)}'  Can't be parsed In CallableStatement
Date: Tue, 3 Oct 2006 17:49:12 +0800
Message-ID: <003401c6e6d1$2ea44a30$6506a8c0@xtshao> (raw)

HI ,
    
a.. JDBC driver build number                   : 407-503 
a.. Server version                             : 8.1.4 
a.. Exact error message and stacktrace         
  Caused by: org.postgresql.util.PSQLException: 不正确的函数或过程在偏移处2溢出。
 at org.postgresql.jdbc2.AbstractJdbc2Statement.modifyJdbcCall(AbstractJdbc2Statement.java:2314)
 at org.postgresql.jdbc2.AbstractJdbc2Statement.<init>(AbstractJdbc2Statement.java:136)
 at org.postgresql.jdbc3.AbstractJdbc3Statement.<init>(AbstractJdbc3Statement.java:40)
 at org.postgresql.jdbc3.Jdbc3Statement.<init>(Jdbc3Statement.java:30)
 at org.postgresql.jdbc3.Jdbc3PreparedStatement.<init>(Jdbc3PreparedStatement.java:23)
 at org.postgresql.jdbc3.Jdbc3CallableStatement.<init>(Jdbc3CallableStatement.java:20)
 at org.postgresql.jdbc3.Jdbc3Connection.prepareCall(Jdbc3Connection.java:44)
 at org.postgresql.jdbc3.AbstractJdbc3Connection.prepareCall(AbstractJdbc3Connection.java:308)


a.. What you were doing, ideally in code form 

   The sql is '{ CALL put_umc_domain_attr (?, ?, ?)}'.    Where I change the sql to '{ call put_umc_domain_attr (?, ?, ?)}', it will be okay.

Here is my code:
        int id = getId(entityId);
        CallableStatement cstmt = null;
        Connection conn = getConnection();
        try {
            cstmt = conn.prepareCall(sqls[SQL_PUT_ATTRIBUTE]);
            Iterator names = parameters.getNames();
            while (names.hasNext()) {
                String name = (String) names.next();
                String value = parameters.getString(name);
                cstmt.setInt(1, id);
                cstmt.setString(2, name);
                cstmt.setString(3, value);

                cstmt.addBatch();
            }

            cstmt.executeBatch();
        }
        catch (SQLException e) {
            throw new AttributeException("set_attribute", e.getMessage(), e);
        }
        finally {
            Jeton.close(cstmt);
            Jeton.close(conn);
        }


I found the codes in class AbstractJdbc2Statement method modifyJdbcCall :

            case 2:  // After {, looking for ? or =, skipping whitespace
                if (ch == '?')
                {
                    outParmBeforeFunc = isFunction = true;   // { ? = call ... }  -- function with one out parameter
                    ++i;
                    ++state;
                }
                else if (ch == 'c')     // I think here may be change to " ch == 'c' || ch == 'C'"
                {  // { call ... }      -- proc with no out parameters
                    state += 3; // Don't increase 'i'
                }
                else if (Character.isWhitespace(ch))
                {
                    ++i;
                }
                else
                {
                    // "{ foo ...", doesn't make sense, complain.
                    syntaxError = true;
                }
                break;


Fengyun


Message-ID: <003401c6e6d1$2ea44a30$6506a8c0@xtshao>
Permalink:  ../003401c6e6d1$2ea44a30$6506a8c0@xtshao/
Also on:    postgresql.org/message-id/003401c6e6d1$2ea44a30$6506a8c0@xtshao

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: fengyun@ceno.cn
  Subject: Re: '{ CALL put_umc_domain_attr (?, ?, ?)}'  Can't be parsed In CallableStatement
  In-Reply-To: <003401c6e6d1$2ea44a30$6506a8c0@xtshao>
  References: <003401c6e6d1$2ea44a30$6506a8c0@xtshao>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox