Getting “Invalid column type” excecption, while using NamedParameterJDBCTemplate for insertion

后端 未结 6 1760
情深已故
情深已故 2021-01-12 17:11

I am using below code while inserting a row into database(oracle 10g xe,jar: ojdbc14.jar)

String sql = \"INSERT INTO SPONSOR_TB(ID,NAME,INDUSTRY_TYPE,IS_REPO         


        
6条回答
  •  [愿得一人]
    2021-01-12 17:57

    In my case I was providing an Enumeration datatype instead of a datatype compatible with VARCHAR2 in database (like String ).

    My query was like :

    private static final String QUERY ="SELECT res.id, FROM result res " +
    "WHERE res.country = :resCountry ";
    

    And at the time of passing the parameter resCountry, I did like this:

    List> listResult = jdbcTemplate.queryForList(QUERY,Country.US);
    

    Now the complaint/exception came from the fact that Country.US was of type Enumeration Country

    I did the following change to make it work.

    List> listResult = jdbcTemplate.queryForList(QUERY,Country.US.name());
    

    After this change it worked fine.

提交回复
热议问题