org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT * FROM USER WHERE EMAIL = ?]; Conversion not supported for type xxx.enums.Gender; nested exception is java.sql.SQLException: Conversion not supported for type xxx.enums.Gender

Spring JIRA | cemo koc | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I have updated our codebase to spring 4.1 and had some problems. I am working with MySQL 5.6 and latest driver (5.1.32) and JDK8. The block below from JdbcUtils is throwing an exception at line `return rs.getObject(index, requiredType);` {code} if (getObjectWithTypeAvailable) { try { return rs.getObject(index, requiredType); } catch (SQLFeatureNotSupportedException ex) { logger.debug("JDBC driver does not support JDBC 4.1 'getObject(int, Class)' method", ex); } catch (AbstractMethodError err) { logger.debug("JDBC driver does not implement JDBC 4.1 'getObject(int, Class)' method", err); } } // Fall back to getObject without type specification... return getResultSetValue(rs, index); {code} I have also evaluated last statement which is working as expected. {code} return getResultSetValue(rs, index); {code} Here is the details: {code} ERROR [2014-09-10 12:44:55,993] com.clovify.lyso.guava.OptionalExtractorFactory: guava extractor expcetion: ! java.sql.SQLException: Conversion not supported for type xxx.enums.Gender ! at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.ResultSetImpl.getObject(ResultSetImpl.java:5121) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.JDBC4ResultSet.getObject(JDBC4ResultSet.java:542) ~[mysql-connector-java-5.1.31.jar:na] ! at org.springframework.jdbc.support.JdbcUtils.getResultSetValue(JdbcUtils.java:197) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.BeanPropertyRowMapper.getColumnValue(BeanPropertyRowMapper.java:311) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.BeanPropertyRowMapper.mapRow(BeanPropertyRowMapper.java:249) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:705) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:641) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! ... 69 common frames omitted ! Causing: org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT * FROM USER WHERE EMAIL = ?]; Conversion not supported for type xxx.enums.Gender; nested exception is java.sql.SQLException: Conversion not supported for type xxx.enums.Gender ! at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:108) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:657) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:692) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:719) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:769) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:211) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] {code} Is there any information I can provide?

    Spring JIRA | 3 years ago | cemo koc
    org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT * FROM USER WHERE EMAIL = ?]; Conversion not supported for type xxx.enums.Gender; nested exception is java.sql.SQLException: Conversion not supported for type xxx.enums.Gender
  2. 0

    I have updated our codebase to spring 4.1 and had some problems. I am working with MySQL 5.6 and latest driver (5.1.32) and JDK8. The block below from JdbcUtils is throwing an exception at line `return rs.getObject(index, requiredType);` {code} if (getObjectWithTypeAvailable) { try { return rs.getObject(index, requiredType); } catch (SQLFeatureNotSupportedException ex) { logger.debug("JDBC driver does not support JDBC 4.1 'getObject(int, Class)' method", ex); } catch (AbstractMethodError err) { logger.debug("JDBC driver does not implement JDBC 4.1 'getObject(int, Class)' method", err); } } // Fall back to getObject without type specification... return getResultSetValue(rs, index); {code} I have also evaluated last statement which is working as expected. {code} return getResultSetValue(rs, index); {code} Here is the details: {code} ERROR [2014-09-10 12:44:55,993] com.clovify.lyso.guava.OptionalExtractorFactory: guava extractor expcetion: ! java.sql.SQLException: Conversion not supported for type xxx.enums.Gender ! at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.ResultSetImpl.getObject(ResultSetImpl.java:5121) ~[mysql-connector-java-5.1.31.jar:na] ! at com.mysql.jdbc.JDBC4ResultSet.getObject(JDBC4ResultSet.java:542) ~[mysql-connector-java-5.1.31.jar:na] ! at org.springframework.jdbc.support.JdbcUtils.getResultSetValue(JdbcUtils.java:197) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.BeanPropertyRowMapper.getColumnValue(BeanPropertyRowMapper.java:311) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.BeanPropertyRowMapper.mapRow(BeanPropertyRowMapper.java:249) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:60) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:705) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:641) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! ... 69 common frames omitted ! Causing: org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT * FROM USER WHERE EMAIL = ?]; Conversion not supported for type xxx.enums.Gender; nested exception is java.sql.SQLException: Conversion not supported for type xxx.enums.Gender ! at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:108) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:657) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:692) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:719) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:769) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] ! at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:211) ~[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE] {code} Is there any information I can provide?

    Spring JIRA | 3 years ago | cemo koc
    org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT * FROM USER WHERE EMAIL = ?]; Conversion not supported for type xxx.enums.Gender; nested exception is java.sql.SQLException: Conversion not supported for type xxx.enums.Gender

    Root Cause Analysis

    1. org.springframework.dao.TransientDataAccessResourceException

      PreparedStatementCallback; SQL [SELECT * FROM USER WHERE EMAIL = ?]; Conversion not supported for type xxx.enums.Gender; nested exception is java.sql.SQLException: Conversion not supported for type xxx.enums.Gender

      at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate()
    2. Spring Framework
      NamedParameterJdbcTemplate.queryForObject
      1. org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:108)[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE]
      2. org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE]
      3. org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE]
      4. org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE]
      5. org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:657)[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE]
      6. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:692)[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE]
      7. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:719)[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE]
      8. org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:769)[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE]
      9. org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.queryForObject(NamedParameterJdbcTemplate.java:211)[spring-jdbc-4.1.0.RELEASE.jar:4.1.0.RELEASE]
      9 frames