【问题标题】:Inserting a JSON as a column in teradata using spring-boot使用spring-boot将JSON作为列插入teradata
【发布时间】:2017-09-06 22:07:05
【问题描述】:

我正在开发一个 Spring Boot 应用程序,我需要将数据插入到 teradata DB 中。 我的表由三列组成:id、Name、Json_data 其中 id 和 name 是 varchar,Json_data 是 JSON

我有一个 pojo 类,其 id 和 name 为 String 类型, JSON_data 为 clob 这可以完美地检索数据(GET操作)

从邮递员插入数据时出现以下错误

2017-09-06 05:39:29.186  WARN 15516 --- [nio-9090-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Can not construct instance of java.sql.Clob: abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of java.sql.Clob: abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
 at [Source: java.io.PushbackInputStream@1eee791; line: 9, column: 15] (through reference chain: com.model.SampleModel["jsondata"])

谁能解释从我的 rest API 中插入示例数据的最佳方法我的 JSON 如下所示:

{
    "id": "23",
    "name": "Navatha",
    "jsondata": "{\"Notes\": \"sample Note\",\"BU\": \"BFS\",\"NumberOfFields\": \"4\"}"
}

【问题讨论】:

  • 非常感谢.. 成功了
  • 我刚刚在此处添加了回复,以便对社区的其他人有用
  • 你能验证我的回复吗?然后对其他成员有用。谢谢!

标签: json spring-boot teradata insert-update


【解决方案1】:

在您的实体中添加注释 Lob

@Lob
String jsondata

【讨论】:

  • @navatha 太好了,你能验证并批准回复吗?所以它对其他成员有用:)
猜你喜欢
  • 2020-02-01
  • 2020-04-10
  • 1970-01-01
  • 2020-05-17
  • 2017-03-31
  • 2019-12-02
  • 1970-01-01
  • 2018-11-14
  • 2021-05-15
相关资源
最近更新 更多