gpt4 book ai didi

java - 捕获 GenericJDBCException

转载 作者:行者123 更新时间:2023-12-01 13:20:21 28 4
gpt4 key购买 nike

我有一个表单页面,当我保存它时,它会覆盖数据库。表单页面中有一个文本框,允许用户输入 4000 个字符,但如果用户输入的字符超过此值,则会出现以下错误:

 ERROR 15:54:05 AbstractFlushingEventListener.performExecutions(301) |
Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update

我知道这是因为它试图添加超出数据库允许的内容。我只是想捕获异常并重定向回表单页面。

当 Controller 将其传递给此行上的句柄请求时,它失败:

return super.handleRequest(request,response);

有什么办法可以做到这一点吗?

最佳答案

try {
/* your code that creates the exception */
} catch (GenericJDBCException e) {
/* redirect back to form page */
}

关于java - 捕获 GenericJDBCException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22073996/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com