Spring Boot informix Jpa 连接
Posted
技术标签:
【中文标题】Spring Boot informix Jpa 连接【英文标题】:Spring Boot informix Jpa connection 【发布时间】:2019-12-25 10:07:10 【问题描述】:我正在尝试使用informix RDBMS 和Spring boot 创建一个Web 服务应用程序。
当我声明 ddl-auto = create
时,它工作得很好,但是当我将它更改为 update
或 none
时,我得到了错误。我的 informix 版本是 9.40.UC8。
spring.datasource.url=jdbc:informix-sqli://*.*.*.*:*/testechange:INFORMIXSERVER=server
spring.datasource.username=
spring.datasource.password=
spring.datasource.tomcat.max-wait=20000
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-idle=20
spring.datasource.tomcat.min-idle=15
spring.datasource.driver-class-name=com.informix.jdbc.IfxDriver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.InformixDialect
spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true
spring.jpa.hibernate.ddl-auto=update
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
server.port=8182
@Entity
@Table(name ="todos")
public class Todo
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id ;
@Column
private String name ;
<dependencies>
<!-- https://mvnrepository.com/artifact/com.ibm.informix/jdbc -->
<dependency>
<groupId>com.ibm.informix</groupId>
<artifactId>jdbc</artifactId>
<version>4.10.6.20151104</version>
</dependency>
</dependencies>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Error accessing tables metadata
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.exception.GenericJDBCException: Error accessing tables metadata
Caused by: org.hibernate.exception.GenericJDBCException: Error accessing tables metadata
Caused by: java.sql.SQLException: Routine (get_data_type) can not be resolved.*
【问题讨论】:
在以update
或none
开始之前,您能否检查表todos
是否真的存在于数据库中?
我修复了这个错误,只是我将 informix JDBC 版本更改为 4.50.2.fix
【参考方案1】:
当您使用更新时,您表示您将与 spring 建立的连接将是动态的,您可以在进行更改时接收到这些更改。
【讨论】:
以上是关于Spring Boot informix Jpa 连接的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot(17)——使用Spring Data JPA
spring boot 系列之四:spring boot 整合JPA
Spring Boot(十五):spring boot+jpa+thymeleaf增删改查示例
[Spring Boot] Adding JPA and Spring Data JPA