java.sql.SQLSyntaxErrorException : unexpected token: (

标签 java sql spring spring-batch hsqldb

抱歉我的英语不好,我是法国人 我需要一点帮助:-)

我有一个java.sql.SQLSyntaxErrorException但我找不到发生了什么。

这是跟踪:

org.springframework.jdbc.datasource.init.ScriptStatementFailedException:
Failed to execute SQL script statement #1 of class path resource
[ddl/ddl-table.sql]: CREATE TABLE user_klesia(noss varchar(15),email
varchar(45),tel_fixe varchar(20),tel_mobile varchar(20)
,statut_consentement varchar(20) ,consentement_offres_date timestamp
NULL,certification_date timestamp NULL,derniere_tentative_date
timestamp NULL,id_web bigint(20) NOT NULL AUTO_INCREMENT,certifie
int(1) DEFAULT '0',date_naissance date ,origine varchar(2) DEFAULT
'K',question_secrete varchar(45),reponse_secrete
varchar(45),liferay_user_id bigint(20),nom varchar(200),prenom
varchar(200),indicateur_tel_fixe varchar(20),code_pays_fixe
varchar(4),indicateur_tel_mobile varchar(20),code_pays_mobile
varchar(4),civilite varchar(15),id_indv_ur
bigint(20),blocage_compte_date timestamp NULL,nb_tentatives
int(1),id_indv_alloc bigint(20),question_certifiante varchar(200)
,reponse_certifiante varchar(200) ,mode_certification varchar(20)
,otp_certifiant varchar(10) ,email_date_maj timestamp NULL
,tel_fixe_date_maj timestamp NULL ,tel_mobile_date_maj timestamp NULL
,id_individu bigint(20),france_connect varchar(45) ,sub varchar(255)
,sso_ima int(1),PRIMARY KEY (id_web)); nested exception is
java.sql.SQLSyntaxErrorException: unexpected token: (   
    at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:492)
    at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.populate(ResourceDatabasePopulator.java:240)
    at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:48)
    at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.initDatabase(EmbeddedDatabaseFactory.java:200)
    at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory.getDatabase(EmbeddedDatabaseFactory.java:157)
    at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder.build(EmbeddedDatabaseBuilder.java:270)
    at fr.koudama.batch.excellent.test.launchJob(test.java:82)

这是我的 SQL 语句:

CREATE TABLE user_klesia(noss varchar(15),
                         email varchar(45),
                         tel_fixe varchar(20),
                         tel_mobile varchar(20),
                         statut_consentement varchar(20), 
                         consentement_offres_date timestamp NULL,
                         certification_date timestamp NULL,
                         derniere_tentative_date timestamp NULL,
                         id_web bigint(20) NOT NULL AUTO_INCREMENT,
                         certifie int(1) DEFAULT '0',
                         date_naissance date,
                         origine varchar(2) DEFAULT 'K',
                         question_secrete varchar(45),
                         reponse_secrete varchar(45),
                         liferay_user_id bigint(20),
                         nom varchar(200),
                         prenom varchar(200),
                         indicateur_tel_fixe varchar(20),
                         code_pays_fixe varchar(4),
                         indicateur_tel_mobile varchar(20),
                         code_pays_mobile varchar(4),
                         civilite varchar(15),
                         id_indv_ur bigint(20),
                         blocage_compte_date timestamp NULL,
                         nb_tentatives int(1),
                         id_indv_alloc bigint(20),
                         question_certifiante varchar(200),
                         reponse_certifiante varchar(200),
                         mode_certification varchar(20),
                         otp_certifiant varchar(10),
                         email_date_maj timestamp NULL,
                         tel_fixe_date_maj timestamp NULL,
                         tel_mobile_date_maj timestamp NULL,
                         id_individu bigint(20),
                         france_connect varchar(45),
                         sub varchar(255),
                         sso_ima int(1),
                         PRIMARY KEY (id_web));

最佳答案

您的 DDL 有一些问题:

  • bigintint 不能有大小。您需要将 bigint(20) 更改为 bigint,将 int(1) 更改为 int
  • auto_increment 不存在,但它被实现为 identity

我修复了您的 SQL 并在 HyperSQL 2.3.4 中对其进行了测试。现在效果很好:

CREATE TABLE user_klesia (
  noss varchar(15),
  email varchar(45),
  tel_fixe varchar(20),
  tel_mobile varchar(20) ,
  statut_consentement varchar(20) ,
  consentement_offres_date timestamp NULL,
  certification_date timestamp NULL,
  derniere_tentative_date timestamp NULL,
  id_web bigint identity NOT NULL,
  certifie int DEFAULT '0',
  date_naissance date ,
  origine varchar(2) DEFAULT 'K',
  question_secrete varchar(45),
  reponse_secrete varchar(45),
  liferay_user_id bigint,
  nom varchar(200),
  prenom varchar(200),
  indicateur_tel_fixe varchar(20),
  code_pays_fixe varchar(4),
  indicateur_tel_mobile varchar(20),
  code_pays_mobile varchar(4),
  civilite varchar(15),
  id_indv_ur bigint,
  blocage_compte_date timestamp NULL,
  nb_tentatives int,
  id_indv_alloc bigint,
  question_certifiante varchar(200) ,
  reponse_certifiante varchar(200) ,
  mode_certification varchar(20) ,
  otp_certifiant varchar(10) ,
  email_date_maj timestamp NULL ,
  tel_fixe_date_maj timestamp NULL ,
  tel_mobile_date_maj timestamp NULL ,
  id_individu bigint,
  france_connect varchar(45),
  sub varchar(255),
  sso_ima int,
  PRIMARY KEY (id_web)
);

关于java.sql.SQLSyntaxErrorException : unexpected token: (,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51133443/

相关文章:

spring - 为不同 URL 的多个角色授权请求

java - Android根据 ListView 位置更改另一个 Activity 中的图像?

Java View 模板库

c# - 如何修改自动生成的 Entity Framework DbContext 属性?

mysql - 在 MySQL 中使用 SELECT 语法创建表

php - 如何从mysql获取未读消息

java - 如何禁用对 jamon 管理页面的公共(public)访问?

java - 登录 Spark

java - 由于文件重命名导致输入更改时更改编辑器上的标题

java - webapps 的 Spring 配置 -> WEB-INF 中的位置是强制的吗?