简体   繁体   English

错误: <column-name> 是没有时区的时间,但表达的类型字符是变化的

[英]Error: the <column-name> is of time without time zone but expression is of type character varying

i am using a postgresql database. 我正在使用postgresql数据库。 I insert the values to the database from a java class. 我从java类中将值插入数据库。 I have declared the field which is of datatype time without time zone as a String. 我已经声明了没有时区的数据类型时间字段作为字符串。 I am not knowing how to parse and send it to database which matches the data type? 我不知道如何解析并将其发送到与数据类型匹配的数据库? How do I do this? 我该怎么做呢?

public static void User(Form t)
{
String insertTableSQL = "INSERT INTO DBUSER"
    + "(USER_ID, USERNAME,CREATED_DATE) VALUES"
    + "(?,?,?)";
PreparedStatement ps = dbConnection.prepareStatement(insertTableSQL);
ps.setString(1, t.getUserID());
ps.setString(2, t.getuserName());
ps.setString(3, t.getTime());
ps.executeUpdate();
}

Error: Error: the CREATED_DATE is of time without time zone but expression is of type character varying Hint: try to cast the expression 错误:错误:CREATED_DATE是没有时区的时间,但表达式的类型为字符变化提示:尝试强制转换表达式

Try to add explicit type casting 尝试添加显式类型转换

change 更改
+ "(?,?,?)";
to
+ "(?,?, CAST (? AS time))";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:列“DOJ”的类型是没有时区的时间戳,但表达式的类型是字符变化 - ERROR: column "DOJ" is of type timestamp without time zone but expression is of type character varying 当我在 Jooq 中插入日期时,出现此错误:column creation_date is of type timestamp with time zone but expression is of type character varying - When I insert a date in Jooq, I get this error: column creation_date is of type timestamp with time zone but expression is of type character varying 在 PostgreSQL 查询中将“没有时区的时间”类型读取为字符串(字符变化)类型 - Read 'Time without time zone' type as String(Character varying) type in PostgreSQL query java sql error列的类型为整数,但表达式的类型为字符变化 - java sql error column is of type integer but expression is of type character varying org.postgresql.util.PSQLException:错误:列“标签”是 jsonb 类型,但表达式的类型是字符变化 - org.postgresql.util.PSQLException: ERROR: column "tags" is of type jsonb but expression is of type character varying JOOQ-列“ id”的类型为uuid,但表达式的类型为字符变化 - JOOQ - column “id” is of type uuid but expression is of type character varying 列是 uuid 类型,但表达式是 Spark Scala 中不同的字符类型 - Column is of type uuid but expression is of type character varying in Spark Scala PostgreSQL 参数错误(timestamp with time zone, timestamp without time zone) - PostgreSQL Parameter error (timestamp with time zone, timestamp without time zone) PostgreSQL 提示:您需要重写或转换表达式。 “状态”列的类型是状态,但表达式的类型是字符变化 - PostgreSQL Hint: You will need to rewrite or cast the expression. column “state” is of type status but expression is of type character varying 哪个Java数据类型对应postgresql“没有区域的时间” - Which Java data type corresponds to postgresql “time without zone”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM