再说Could not execute JDBC batch update
来源:互联网 发布:商务时空软件 编辑:程序博客网 时间:2024/05/16 15:44
上一次说了Hibernate这个异常,因为我那次没有把自增的主键设为"increment",不过后来发现其他情况也会出现这个异常,原因情况比较多,归纳了一下,觉得还是因为Hibernate并没有跟数据库有非常密切的交互,所以后台数据库里出问题了,也不能及时反映在Hibernate中,而仅仅用一个Could not execute JDBC batch update来应付开发人员~
解决办法就是,我们可以去查看数据库日志,每当Hibernate出现这个异常的时候,一般来说都是因为不满足数据库的约束造成的,比如唯一约束,外键约束,自增约束等等~ 我们只要配置好了数据库的日志,那么日志就会清清楚楚地告诉我们是哪里出了问题~
这里我来简单说一下PostgreSQL的日志配置方法:
1- 打开PostgreSQL安装目录下的data文件夹下的postgresql.conf文件,修改 # - What to Log - 那里如下:
# - What to Log -
debug_print_parse = off
debug_print_rewritten = off
debug_print_plan = off
debug_pretty_print = off
log_connections = on
log_disconnections = on
log_duration = on
log_line_prefix = '<%t;PID:%p;Command Tag:%i;SessionID:%c;SessionLineNum:%l;SessionStartTime:%s;TranID:%x>' # Special values:
# %u = user name
# %d = database name
# %r = remote host and port
# %h = remote host
# %p = PID
# %t = timestamp (no milliseconds)
# %m = timestamp with milliseconds
# %i = command tag
# %c = session id
# %l = session line number
# %s = session start timestamp
# %x = transaction id
# %q = stop here in non-session
# processes
# %% = '%'
# e.g. '<%u%%%d> '
log_statement = 'all' # none, ddl, mod, all
#log_hostname = off
debug_print_parse = off
debug_print_rewritten = off
debug_print_plan = off
debug_pretty_print = off
log_connections = on
log_disconnections = on
log_duration = on
log_line_prefix = '<%t;PID:%p;Command Tag:%i;SessionID:%c;SessionLineNum:%l;SessionStartTime:%s;TranID:%x>' # Special values:
# %u = user name
# %d = database name
# %r = remote host and port
# %h = remote host
# %p = PID
# %t = timestamp (no milliseconds)
# %m = timestamp with milliseconds
# %i = command tag
# %c = session id
# %l = session line number
# %s = session start timestamp
# %x = transaction id
# %q = stop here in non-session
# processes
# %% = '%'
# e.g. '<%u%%%d> '
log_statement = 'all' # none, ddl, mod, all
#log_hostname = off
注意:log_line_prefix 那行配置的就是你将从日志文件中看到的东西~ 执行语句,变量都包括了,一览无余~
2- 修改完别忘了保存,然后在控制面板-管理工具-服务中重启PostgreSQL服务~ 查看日志的地方可以在data文件夹下的pg_log文件夹里,也可以到pgAdmin中,选中数据库,然后点“工具-服务器状态-日志档”。
哈哈,这回再有Could not execute JDBC batch update异常,就再也不怕找不到原因摸不着头脑了~
有疑问或者建议,随时跟我联系给我留言~
- 再说Could not execute JDBC batch update
- Could not execute JDBC batch update
- SQLGrammarException: Could not execute JDBC batch update
- Could not execute JDBC batch update....
- Could not execute JDBC batch update问题
- Could not execute JDBC batch update
- Could not execute JDBC batch update
- Could not execute JDBC batch update
- Could not execute JDBC batch update
- Could not execute JDBC batch update
- Could not execute JDBC batch update
- Hibernate抛异常Could not execute JDBC batch update
- org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
- org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
- org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
- Could not execute JDBC batch update异常的解决办法
- org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
- org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
- 卡巴就是卡巴 真 NX啊
- EAM(Enterprise Asset Management)--面向资产密集型企业的企业信息化解决方案
- SQL Server 2000 标准版安装(一)
- CRM(customer relationship management) --客户关系管理
- Iframe网马批量清除
- 再说Could not execute JDBC batch update
- 常见网络攻击手段原理分析
- 添加到收藏夹和设置首页代码大全
- SWT 和 JFace,第 1 部分: 创建简单的 SWT 应用程序
- Nokia关于FC的一些有用链接
- 一个查当前月库存的算法及详解
- SWT 和 JFace, 第 2 部分: 了解菜单、列表、组合框、表和树
- 忍痛割肉
- 创建表头固定,表体可滚动的GridView