Hi Could you please help me with this?
jdbcTemplate.update("update training.link_validity set start_time=now() , end_time=(NOW() + INTERVAL ?) where id=1", new Object[] { 6 });
It's working fine in PgAdmin but throwing an error here.
Error : Caused by: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of [Ljava.lang.Object;. Use setObject() with an explicit Types value to specify the type to use. at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:2142)
Your statement in your description doesn't match the one from the screenshot, but anyhow:
You can set (and play with) the explicit SQLTypes
in the JDBCTemplate. So try this out (and drop the explicit array creation if you want)
jdbcTemplate.update("update training.link_validity set start_time=now() , end_time=(NOW() + INTERVAL ? HOUR) where id=1", "6" , java.sql.Types.VARCHAR);
(I suppose the interval ? parameter is a string literal, but if it is a number, just change the types accordingly)