title: postgres insert string to numeric column - auto-typecast does not happen
body: <p>There is a table in postgres  DB test1  having schema :<a href="https://i.stack.imgur.com/PfAFV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PfAFV.jpg" alt="enter image description here"></a></p>
  
  <p>We are using spring frameworks jdbcTemplate to insert data as below:  </p>
  
  <pre><code>Object[] params = {"978","tour"};
  
  jdbcTemplate.update("insert into test1 values (?,?)", params);
  </code></pre>
  
  <p>But this gives the exception :</p>
  
  <blockquote>
    <p>org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [insert into test1 values (?,?)]; nested exception is org.postgresql.util.PSQLException: <em>ERROR: column "id" is of type integer but expression is of type character varying</em>
    ERROR: column "id" is of type integer but expression is of type character varying</p>
  </blockquote>
  
  <p>This works for Oracle database through implicit type conversion, but postgres does nOt seem to work that way.</p>
  
  <p><strong>Could this be an issue with postgres driver?</strong> </p>
  
  <p>A workaround would  be to  cast explicitly:</p>
  
  <pre><code>insert into test1 values (?::numeric ,?)
  </code></pre>
  
  <p>But is there  better way to do the conversion as this does not seem like a good solution since there are lot of queries to be modified and also there can be other such casting issues too.  </p>
  
  <p>Is there some parameter that can be set at DB level to perform an auto cast?</p>