NutzCN Logo
问答 创建符合主键 table 错误
发布于 136天前 作者 Rekoe 120 次浏览 复制 上一个帖子 下一个帖子
标签:

本地没问题 在服务器上有这个错误 导致创建失败

2017-01-11 13:02:22,011 [ERROR][org.nutz.mvc.impl.NutLoading] - Error happend during start serivce!
org.nutz.dao.DaoException: !Nutz SQL Error: 'CREATE TABLE statistics(
tag INT(32),
num INT(32),
tim TIMESTAMP NULL DEFAULT NULL,
PRIMARY KEY (tag,tim)
) ENGINE=InnoDB CHARSET=utf8'
PreparedStatement: 
'CREATE TABLE statistics(
tag INT(32),
num INT(32),
tim TIMESTAMP NULL DEFAULT NULL,
PRIMARY KEY (tag,tim)
) ENGINE=InnoDB CHARSET=utf8'
CaseMessage=All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:187)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:248)
	at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:236)
	at org.nutz.dao.impl.NutDao.execute(NutDao.java:973)
	at org.nutz.dao.impl.jdbc.mysql.MysqlJdbcExpert.createEntity(MysqlJdbcExpert.java:173)
	at org.nutz.dao.impl.EntityHolder.reloadEntity(EntityHolder.java:86)
	at org.nutz.dao.impl.NutDao.create(NutDao.java:784)
	at org.nutz.dao.util.Daos.createTablesInPackage(Daos.java:539)
	at com.rekoe.MainSetup.init(MainSetup.java:55)
	at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:277)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:121)
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
	at com.caucho.server.dispatch.FilterManager.createFilter(FilterManager.java:204)
	at com.caucho.server.dispatch.FilterManager.init(FilterManager.java:105)
	at com.caucho.server.webapp.WebApp.startImpl(WebApp.java:3687)
	at com.caucho.server.webapp.WebApp$StartupTask.run(WebApp.java:5196)
	at com.caucho.env.thread2.ResinThread2.runTasks(ResinThread2.java:173)
	at com.caucho.env.thread2.ResinThread2.run(ResinThread2.java:118)
6 回复

tag要用not null

这个和数据库版本有关系? 有的数据库就没问题

加了还是操作

org.nutz.dao.DaoException: !Nutz SQL Error: 'CREATE TABLE statistics(
tag INT(32) NOT NULL,
num INT(32),
tim TIMESTAMP NULL DEFAULT NULL,
PRIMARY KEY (tag,tim)
) ENGINE=InnoDB CHARSET=utf8'
PreparedStatement: 
'CREATE TABLE statistics(
tag INT(32) NOT NULL,
num INT(32),
tim TIMESTAMP NULL DEFAULT NULL,
PRIMARY KEY (tag,tim)
) ENGINE=InnoDB CHARSET=utf8'
CaseMessage=All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:187)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)

我在本地测试没问题

2017-01-11 18:04:38,903 [DEBUG][org.nutz.dao.impl.sql.run.NutDaoExecutor] - CREATE TABLE statistics_1(
tag INT(32),
num INT(32),
tim TIMESTAMP NULL DEFAULT NULL,
PRIMARY KEY (tag,tim)
) ENGINE=InnoDB CHARSET=utf8

tim也要改哦

mysql新版本的兼容性问题

添加回复
请先登陆
回到顶部