gpt4 book ai didi

java - org.h2.jdbc.JdbcSQLException : Column count does not match when it does

转载 作者:行者123 更新时间:2023-12-02 01:58:20 31 4
gpt4 key购买 nike

我已经设置了以下 POJO:

@Getter
@Setter
@AllArgsConstructor
@Entity
@Table(name = "SpreadsheetRequest")
public class SpreadsheetRequest {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(updatable = false, nullable = false, unique = true)
@Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE)
private Integer id;

private String spreadsheetId;
private String name;
private String range;

@SuppressWarnings("unused")
public SpreadsheetRequest() {
setSpreadsheetId(null);
setName(null);
setRange(null);
}
}

并配置我的环境如下:

spring.h2.console.enabled=true
spring.h2.console.path=/h2
spring.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.initialization-mode=embedded
spring.jpa.properties.hibernate.hbm2ddl.import_files=classpath://resources/import.sql
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=create

import.sql 如下所示:

INSERT INTO SPREADSHEET_REQUEST VALUES ('DYsErzRPCLEoYYzQkemEAeerYiQ3Usyn','Test','Sheet1!A1:A12');

我在加载时不断收到以下错误:

Caused by: org.h2.jdbc.JdbcSQLException: Column count does not match; SQL statement:
INSERT INTO SPREADSHEET_REQUEST VALUES ('DYsErzRPCLEoYYzQkemEAeerYiQ3Usyn','Test','Sheet1!A1:A12') [21002-197]

是什么原因造成的?

最佳答案

原因是

Column count does not match

您尝试插入 3 列,而您的实体(因此数据库中的表)有 4 列。在查询中包含 id:

INSERT INTO SPREADSHEET_REQUEST VALUES (1, 'DYsErzRPCLEoYYzQkemEAeerYiQ3Usyn','Test','Sheet1!A1:A12');

关于java - org.h2.jdbc.JdbcSQLException : Column count does not match when it does,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52006774/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com