我有一个关于PreparedStatementCallback的问题,如下所示:

 Error! Conflict [#409]: PreparedStatementCallback; SQL [EXEC de_table ?, ?, ?, ?, ?, ?, ?, ?]; Data truncation; nested exception is java.sql.DataTruncation: Data truncation


内容:

我有一个小节,用于用应用程序生成具有值的表,直到最近我发现除了我正在测试的4个数据库之一外,没有问题。问题是,我在其他一些数据库上对其进行了测试后,我看不到为什么会如此,并且此页面按预期工作。因此,我假设代码是好的,但是数据不是。我执行了相同的过程来填充表,但是可惜错误仍然存​​在。

我的请求网址包含以下内容:

accessInd: Any
client: %
endDate: 2020-02-15 23:59:59
entDate: 2020-01-30 11:32:49
entitlementSetMode: 1
entitlementType: Historical
groupItem: %
groupType: 15
service: %
site: %
siteName: %
startDate: 2020-01-30 00:00:00
subservice: %
type: %
userLogin: %


需要传递到准备好的语句中的所有值如下:

                        exampleTable.getSite(),
                        exampleTable.getGroupType(),
                        exampleTable.getGroupItem(),
                        exampleTable.getService(),
                        exampleTable.getType(),
                        exampleTable.getSubservice(),
                        exampleTable.getEndDate(),
                        exampleTable.getMaxRowCount()


有人知道为什么这行不通或没有帮助吗?此外,如果有人想知道,该百分比仅用于请求与该值相关的所有内容。谢谢。

最佳答案

检查您的数据库字段类型/大小是否支持您尝试放入的数据长度。

可以工作的三个数据库和不能工作的三个数据库之间可能存在细微的模式差异。

假设yourdb.exampleTable.site字段是VARCHAR(10),而exampleTable.getSite()"my-site-name-is-more-than-10-chars-long",这将引发此java.sql.DataTruncation异常。

07-24 19:22
查看更多