文档用途
最近项目中,经常遇到需要URL里添加stringtype=unspecified情况。什么情况下需要添加呢?
详细信息
1、直接URL添加stringtype=unspecified
2、程序里报类似ERROR: column is of type timestamp without time zone but expression is of type character varying错误 ,取出SQL放到数据库正常执行,URL再添加stringtype=unspecified
pg社区对此处的解释
stringtype = String
specify the type to use when binding PreparedStatement parameters set via setString(). If stringtype is set to varchar(the default), such parameters will be sent to the server as varchar parameters. If stringtype is set to unspecified, parameters will be sent to the server as untyped values, and the server will attempt to infer an appropriate type. This is useful if you have an existing application that uses setString() to set parameters that are actually some other type, such as integers, and you are unable to change the application to use an appropriate method such as setInt().