dbexception.java,org.hibernate.tool.schema.spi.CommandAcceptanceException:使用h2和JPA在SpringBoot中通过JDBC...

使用h2数据库和JPA运行spring boot时,出现以下错误。

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement

at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]

at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]

这是由于低于一

Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "CREATE TABLE EXCHANGE_VALUE (ID INTEGER NOT NULL, CONVERSION_MULTIPLE DECIMAL(19,2), FROM[*] VARCHAR(255), PORT INTEGER NOT NULL, TO VARCHAR(255), PRIMARY KEY (ID)) "; expected "identifier"; SQL statement:

create table exchange_value (id integer not null, conversion_multiple decimal(19,2), from varchar(255), port integer not null, to varchar(255), primary key (id)) [42001-197]

at org.h2.message.DbException.getJdbcSQLException(DbException.java:357) ~[h2-1.4.197.jar:1.4.197]

at org.h2.message.DbException.getSyntaxError(DbException.java:217) ~[h2-1.4.197.jar:1.4.197]

我的hibernate课

import java.math.BigDecimal;

import javax.persistence.Entity;

import javax.persistence.GeneratedValue;

import javax.persistence.GenerationType;

import javax.persistence.Id;

import javax.persistence.Table;

@Entity

@Table(name="Exchange_Value")

public class ExchangeValue {

@Id

@GeneratedValue(strategy=GenerationType.AUTO)

private int id;

private String from;

private String to;

private BigDecimal conversionMultiple;

private int port;

public ExchangeValue() {

}

public ExchangeValue(String from, String to, BigDecimal conversionMultiple) {

super();

// this.id = id;

this.from = from;

this.to = to;

this.conversionMultiple = conversionMultiple;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

}

application.properties在下面

spring.application.name=currency-exchange-service

server.port=8000

spring.jpa.hibernate.ddl-auto= create-drop

只想知道我在代码中缺少的内容,尝试添加spring.jpa.hibernate.ddl-auto = create-drop,但没有帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值