1
回答
当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'blog' 中的标识列插入显式值。
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

@JFinal 你好,想跟你请教个问题:

使用目前最新的JFinal框架+MSSQL,数据库驱动配置JTDS。运行JFinalDemo时,当插入Blog就会出现下面的异常。

2014-04-21 18:26:36
[ERROR]-[Thread: qtp14440243-22]-[com.jfinal.core.ActionHandler.handle()]: /blog/save
com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'blog' 中的标识列插入显式值。
	at com.jfinal.plugin.activerecord.Model.save(Model.java:329)
	at com.demo.blog.BlogController.save(BlogController.java:22)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:55)
	at com.jfinal.validate.Validator.intercept(Validator.java:61)
	at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51)
	at com.demo.blog.BlogInterceptor.intercept(BlogInterceptor.java:13)
	at com.jfinal.core.ActionInvocation.invoke(ActionInvocation.java:51)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:73)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:72)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:365)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
	at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLException: 当 IDENTITY_INSERT 设置为 OFF 时,不能为表 'blog' 中的标识列插入显式值。
	at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372)
	at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988)
	at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2421)
	at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:671)
	at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:613)
	at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:572)
	at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:727)
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
	at com.jfinal.plugin.activerecord.Model.save(Model.java:324)
	... 35 more



我也参考了http://www.oschina.net/question/130045_73064这个问答,不知现在新版有没已经解决了该问题?


举报
顶部