com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 无效的默认值 'ver_date'



我们有一个指定表结构的规范文件,java程序在安装时创建表,规范文件如下,

customer {
attributes = [
{ name : custId, type ="string:100" , key=true}
{ name : ver-date, type: timestamp , key=true}
{ name : updates, type = "string:8000" }
{ name : created-date, type : timestamp }
{ name : created-userId, type = "string:200" }
{ name : verifier-userId, type = "string:200" }
{ name : remark, type = "string:8000" }
]
}
The corresponding generated create statment fails with error as below as below,
Query executed : CREATE TABLE `customer` ( 
`verifier_userId` VARCHAR(200) binary ,
`custId` VARCHAR(100) binary ,
`remark` VARCHAR(8000) binary ,
`created_date` timestamp  NULL,
`ver_date` timestamp ,
`updates` VARCHAR(8000) binary ,
`created_userId` VARCHAR(200) binary ,
primary key (`custId`,`ver_date`))
**com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Invalid default value for 'ver_date'**
at sun.reflect.GeneratedConstructorAccessor6.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3978)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3914)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2495)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1903)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2124)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2058)
at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5158)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2043)
at     com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:384)

当ver_date是主键时,问题似乎没有给它一个默认值,因为它也不能为null。

这里的挑战是,我们不能更改规范文件以及生成"create语句"的java程序。

所使用的数据库版本如下,mysql版本14.14 Distrib 5.7.29,用于Linux(x86_64(,使用EditLine包装器

数据库服务器中是否有任何设置会影响这一点,并且可以进行修改以确保其正常工作?真的很感谢你的帮助。

我们将sql_mode保持为空,然后它就工作了。