简体   繁体   中英

Error while inserting record in database

Sometime in production we face this problem , I have tried to search the cause of this but not yet good luck.

com.sybase.jdbc3.jdbc.SybSQLException: The parameter of type 61 did not have a valid value.

When we run the query manually it works fine which gave below error.So i think query is fine.

        SQL state [ZZZZZ]; error code [3814]; The parameter of type 61 did not have a valid value.
    ; nested exception is com.sybase.jdbc3.jdbc.SybSQLException: The parameter of type 61 did not have a valid value.
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:602)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:811)
    at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:833)
    at org.springframework.jdbc.object.SqlUpdate.updateByNamedParam(SqlUpdate.java:248)
    at com.cachestore.sql.PTMSSqlUpdate.updateByNamedParam(PTMSSqlUpdate.java:35)
    at com.cachestore.PTMSCacheStore.store(PTMSCacheStore.java:277)
    ... 6 more
    Caused by: com.sybase.jdbc3.jdbc.SybSQLException: The parameter of type 61 did not have a valid value.
    at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
    at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
    at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown Source)
    at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
    at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
    at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(Unknown Source)
    at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(Unknown Source)
    at com.sybase.jdbc3.jdbc.SybPreparedStatement.executeUpdate(Unknown Source)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:817)
    at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:1)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:586)
    ... 11 more

Can you guys help me to find out what could be the possible reason for error The parameter of type 61 did not have a valid value. , The field is of char(2) type where i suspects.

It happens very rarely so we are not able to reproduce it.Any help will be appreciated.

This is a Sybase error message.

Explanation: Command failed due to invalid or illegal request. Check syntax, semantics, and permissions. Take any corrective action indicated by message.

Take a look at the Documentation

Try to catch the Exception and print the param list with values in your catch statement, this will enable you to check the values when it happens.

Unfortunately you have not shown us your code and your DB schema. But I think that exception is very clear. It says that 2 types: the java type and the DB type are not compatible.

As far as I understand you are trying to insert char or may be char[] into DB column of type varchar or something like that. Check this again. Probably you have to turn your char array into string before inserting it into DB.

Sybase type 61 is TDS_DATETIME (0x3D = 61 decimal). This types described in TDS 5.0 Reference Pages Datatype Summary .
It means that server does not likes value due to size, content or something wrong with parameters before that one in TDS packet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM