在不加stringtype=unspecified之前,插入timestamp 会报错:
ERROR: column is of type timestamp without time zone but expression is of type character varying
解决方法:在url后加上stringtype=unspecified
spring.datasource.jtzc.driver-class-name=org.postgresql.Driver
spring.datasource.jtzc.jdbc-url=jdbc:postgresql://localhost:65432/postgres?currentSchema=public&stringtype=unspecified
spring.datasource.jtzc.username=root
spring.datasource.jtzc.password=root
那么这个是什么意思呢?
stringtype=unspecified 表示的是对于 string类型不指定JDBC具体的类型,而是内部自行判断,也就是说,默认是指定为 setString()的,这样对于timestamp就会报错。
所以设置成不指定string类型对应的JDBC 类型,这样就能避免 传string进去不匹配的问题。