実際、Springブートを使用していますが、データベースにテーブルを作成する際にエラーが発生しました。データベースとしてMySQLを使用しています
エラーは
SpringBootでのエラー表示
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like bigint not null, time_created time, primary key (blog_id)) engine=InnoDB' at line 1
テーブルを手動で作成しようとするとエラーが発生します
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like bigint not null, time_created time, primary key (blog_id)) engine=InnoDB' at line 1
私の命令
create table blogs (blog_id integer not null, date_created date, discription varchar(999), dislike bigint not null, like bigint not null, time_created time, primary key (blog_id)) engine=InnoDB;
そして私の実体
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int blogId;
@Column(length = 999)
private String discription;
@CreatedDate
private LocalDate dateCreated;
private LocalTime timeCreated;
private long like;
private long dislike;
public blogs(int blogId, String discription, LocalDate dateCreated, LocalTime timeCreated, long like,
long dislike) {
this.blogId = blogId;
this.discription = discription;
this.dateCreated = dateCreated;
this.timeCreated = timeCreated;
this.like = like;
this.dislike = dislike;
}
エラーはSQLステートメントにあります。LIKE
キーワード/予約語であり、属性の名前として使用することはできません。
SQLステートメントを-から変更します。 create table blogs (blog_id integer not null, date_created date, discription varchar(999), dislike bigint not null, like bigint not null, time_created time, primary key (blog_id)) engine=InnoDB;
に-
CREATE TABLE blogs (blog_id integer not null, date_created date, discription varchar(999), dislike bigint not null, liked bigint not null, time_created time, primary key (blog_id)) engine=InnoDB;
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加