- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
当我使用连接对象调用 createClob
方法时,如下所示:
Clob clob = con.createClob();
抛出以下异常:
Caused by: java.sql.SQLFeatureNotSupportedException: Method org.postgresql.jdbc.PgConnection.createClob() is not yet implemented.
at org.postgresql.Driver.notImplemented(Driver.java:659)
at org.postgresql.jdbc.PgConnection.createClob(PgConnection.java:1246)
at org.apache.commons.dbcp2.DelegatingConnection.createClob(DelegatingConnection.java:868)
at org.apache.commons.dbcp2.DelegatingConnection.createClob(DelegatingConnection.java:868)
我正在使用带有 JDK8 的数据库 PostgreSQL 9.6.2 并使用 commons-dbcp2 连接池,并在 pom.xml 中添加了以下 Postgres 依赖项
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.1</version>
</dependency>
在 org.postgresql.jdbc.PgConnection
类中,createClob 实现如下所示,抛出异常:
@Override
public Clob createClob() throws SQLException {
checkClosed();
throw org.postgresql.Driver.notImplemented(this.getClass(), "createClob()");
}
克服此问题的解决方案或解决方法是什么?或者我们如何在 Postgres 查询中设置 CLOB 数据?
最佳答案
长话短说
application.yml
中设置 spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
或者,persistence.xml
中设置 hibernate.jdbc.lob.non_contextual_creation=true
这是 JBoss 社区中的一个已知错误。
此错误出现在旧版本和 Spring-Boot 2.0.0.RC1 及更高版本的新版本中。
解决方案:
application.yml
中设置 spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
或者,hibernate.jdbc.lob.non_contextual_creation=true
解决方案是在您的属性文件中添加这一行(如果您不使用 spring,则添加类似的内容)
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults= false
因此,您的 application.yml 应该如下所示:
spring:
application:
name: employee-service
datasource:
url: jdbc:postgresql://localhost:5432/db_development
platform: POSTGRESQL
username: ...
password: ...
jpa:
hibernate:
ddl-auto: create-drop
dialect: org.hibernate.dialect.PostgreSQL9Dialect
show_sql: true
properties.hibernate.temp.use_jdbc_metadata_defaults: false
server:
port: 8080
引用:
https://o7planning.org/en/11661/spring-boot-jpa-and-spring-transaction-tutorial
hibernate with c3p0: createClob() is not yet implemented
感谢 Binakot 的评论。我已经更新了帖子。
关于java - 未实现 Postgres 错误方法 org.postgresql.jdbc.PgConnection.createClob(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43905119/
我正在使用带有 Oracle 10g 的 Hibernate 3.5.6。我在初始化期间看到以下异常,但应用程序本身工作正常。这个异常的原因是什么?以及如何纠正? 异常(exception) 禁用上下
我正在尝试测试createClob()方法 String conStr = "jdbc:teradata://..."; Class.forName("com.teradata.jdbc.Tera
在我的项目中,我开始使用 c3p0使用 hibernate 重新连接到数据库,因为 hibernate 不会在数据库故障时恢复连接。 org.hibernate
异常 启动 spring-boot 应用程序时我收到了: 引起:java.sql.SQLFeatureNotSupportedException:方法 org.postgresql.jdbc.PgCo
我该如何解决这个错误: java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccesso
好像是 Hibernate.createClob(Reader reader, int length)在 3.6.x 版本中已弃用 它建议使用使用 LobHelper.createClob(Reade
当我使用连接对象调用 createClob 方法时,如下所示: Clob clob = con.createClob(); 抛出以下异常: Caused by: java.sql.SQLFeature
我将 hibernate 配置为使用 Posgresql org.hibernate.dialect.PostgreSQL92Dialect org.postgresql.Driver
我在 Oracle 11.2.0.3 数据库中加载了一个 Java 程序。我正在使用 Oracle 的 Server-Side Internal Driver与主机数据库通信。 问题是当我尝试将数据插
我正在使用 spring boot 命令行运行器应用程序,它在 PostGIS 方言中挂起,下面的堆栈跟踪包含正在发生的事情。无法理解出了什么问题,我有 hibernate 空间查询。 2018-04
我已经为 Spring Batch 创建了一个小型的 hello world 项目: 构建.gradle: buildscript { repositories { maven
我想用 hibernate/postgresql 9.1.1 创建一个 BLOB 字段 为什么我会在日志中看到这条消息: INFO [org.hibernate.engine.jdbc.intern
我是一名优秀的程序员,十分优秀!