java.sql.SQLException: JZ0TE: Attempted conversion between an illegal pair of types.

From: Axel HONFI (Axel.Honf..nvienna.org)
Date: Wed Oct 22 2003 - 05:14:33 EDT

  • Next message: Andrus Adamchik: "Re: java.sql.SQLException: JZ0TE: Attempted conversion between an illegal pair of types."

    Hello!

    I am trying to use cayenne with an underlying Sybase Database.
    I'm trying to update an object called WebRole, where the primary key is a
    meaningful SMALLINT called role_id and the changeable parameter a VARCHAR
    called description.

    DataContext ctxt =
    BasicServletConfiguration.getDefaultContext(request.getSession());
     Expression exp = ExpressionFactory.matchDbExp("role_id",new
    Short("9999"));
    SelectQuery query = new
    SelectQuery(org.unodc.applications.cms.cayenne.WebRole.class,exp);
    query.setLoggingLevel(org.apache.log4j.Level.INFO);
    List roles = ctxt.performQuery(query);
    WebRole role = (WebRole)roles.get(0);
    role.setDescription("Changed Description....");
    ctxt.commitChanges(org.apache.log4j.Level.INFO);

    The following exception is thrown:

    INFO QueryLogger: UPDATE dbo.web_role SET description = ? WHERE role_id =
    ?
    INFO QueryLogger: [bind: 'Changed Description....', 9999]
    INFO Abstract Type set: Changed Description....(class java.lang.String) -
    12
    INFO Abstract Type set: 9999(class java.lang.Short) - 5
    INFO QueryLogger: *** error.
    java.sql.SQLException: JZ0TE: Attempted conversion between an illegal pair
    of types. Valid database
    datatypes are: 'Double, Float, BigDecimal, Boolean, Integer, Long, byte[],
    String'
            at
    com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:487)
            at
    com.sybase.jdbc2.jdbc.Convert.objectToLongValue(Convert.java:293)
            at com.sybase.jdbc2.jdbc.Convert.objectToInt(Convert.java:136)
            at
    com.sybase.jdbc2.jdbc.SybPreparedStatement.setObject(SybPreparedStatement.java:434)
            at
    com.sybase.jdbc2.jdbc.SybPreparedStatement.setObject(SybPreparedStatement.java:500)
            at
    org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:228)
            at
    org.objectstyle.cayenne.access.types.AbstractType.setJdbcObject(AbstractType.java:81)
            at
    org.objectstyle.cayenne.dba.JdbcAdapter.bindParameter(JdbcAdapter.java:438)
            at
    org.objectstyle.cayenne.dba.sybase.SybaseAdapter.bindParameter(SybaseAdapter.java:118)
            at
    org.objectstyle.cayenne.access.trans.BatchQueryBuilder.bindParameters(BatchQueryBuilder.java:143)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdateAsIndividualQueries(DataNode.java:567)
            at
    org.objectstyle.cayenne.access.DataNode.runBatchUpdate(DataNode.java:477)
            at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:287)
            at
    org.objectstyle.cayenne.access.ContextCommit.commit(ContextCommit.java:188)
            at
    org.objectstyle.cayenne.access.DataContext.commitChanges(DataContext.java:723)
            at
    org.unodc.applications.cms.PageManager.updateRole(PageManager.java:88)

    Has anyone encountered a similar problem?

    Thanks

    Axel



    This archive was generated by hypermail 2.0.0 : Wed Oct 22 2003 - 05:15:11 EDT