[英]PSQL/Spring Boot type syntax error for new column data that I am trying to add
Using Postgres and Spring Boot.使用 Postgres 和 Spring Boot。 Running into the following error when I try to add the following column and data to my table.当我尝试将以下列和数据添加到表中时遇到以下错误。
psql:resorts.sql:51: ERROR: invalid input syntax for type smallint: "https://someurl.com/that-im/trying-to-add/"
LINE 24: 'https://someurl.com/that-im/trying-to-add/'
Where I add in the column in my Spring Boot Model the column above is a short
but I clearly define this column as a String
as seen here:我在 Spring Boot Model 的列中添加了上面的列,但我清楚short
将此列定义为String
,如下所示:
@Column(name = "things")
private short things;
@Column(name = "item_url")
private String itemUrl;
My sql file where I insert the data into the database looks like this:我将数据插入数据库的 sql 文件如下所示:
INSERT INTO table (
...,
things,
item_url
) VALUES (
...,
5,
'https://someurl.com/that-im/trying-to-add/'
),(
When I remove the column for item_url
and remove it and the url from the SQL file everything works, but as soon as I put them back in I get the error above.当我删除item_url
的列并从 SQL 文件中删除它和 url 时,一切正常,但是一旦我把它们放回去,我就会得到上面的错误。 Any help would be appreciated.任何帮助,将不胜感激。
What ended up being the case was that when the table in my database was initially created I had accidentally labeled the type for the item_url
as a short.最终的情况是,当我最初创建数据库中的表时,我不小心将item_url
的类型标记为短。 Despite changing it in the SB model file to a String it still wouldn't take on the table.尽管在 SB 模型文件中将其更改为字符串,但它仍然不会出现在桌面上。
From there I attempted to DROP TABLE IF EXISTS
which deleted my table but for some reason would not allow to re-create a table with the old name.从那里我尝试DROP TABLE IF EXISTS
删除了我的表,但由于某种原因不允许使用旧名称重新创建表。 So I went into the SB model file and SQL seeder file and changed the name of the table to something else.所以我进入了 SB 模型文件和 SQL 种子文件并将表的名称更改为其他名称。 From there it was able to create aa new table with all of the correct data and types with no errors.从那里它能够创建一个包含所有正确数据和类型且没有错误的新表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.