标题翻译
DataIntegrityViolationException: Data truncation regarding PreparedStatementCallback
问题
我有一个关于PreparedStatementCallback的问题,如下所示:
错误!冲突[#409]:PreparedStatementCallback;SQL [EXEC de_table?,?,?,?,?,?,?,?];数据截断;嵌套异常是java.sql.DataTruncation:数据截断
背景:
我有一个部分用于从我的应用程序生成带有值的表,直到最近,我发现除了我测试的4个数据库中的一个之外,都没有问题。问题是,我不明白为什么会出现这种情况,因为我已经在其他几个数据库上进行了测试,而且这个页面的工作效果如预期。因此,我假设代码没问题,但数据有问题。我已经执行了相同的过程来填充表格,但是遗憾的是错误仍然存在。
我的请求URL包括以下内容:
accessInd:任意
client:%
endDate:2020-02-15 23:59:59
entDate:2020-01-30 11:32:49
entitlementSetMode:1
entitlementType:历史记录
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()
有人知道为什么这不起作用吗,或者有任何帮助吗?此外,如果有人想知道,%只是用于请求与该值相关的所有内容。谢谢。
英文翻译
I've an issue regarding a PreparedStatementCallback which is showen as the following:
Error! Conflict [#409]: PreparedStatementCallback; SQL [EXEC de_table ?, ?, ?, ?, ?, ?, ?, ?]; Data truncation; nested exception is java.sql.DataTruncation: Data truncation
Context:
I have a section which is used to produce tables with values from my application, until recently I found there is no problem except for one of the 4 databases I was testing. The issue is that I can't see why this would be the case as I've tested it on a few other dbs and this page is working as expected. Therefore I'm assuming the code is fine, but the data isn't. I've carried out the same procedure to populate the table, but alas the error still is there.
My request URL consists of the following:
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: %
Any the values that need to be passed into the prepared statement are the following:
exampleTable.getSite(),
exampleTable.getGroupType(),
exampleTable.getGroupItem(),
exampleTable.getService(),
exampleTable.getType(),
exampleTable.getSubservice(),
exampleTable.getEndDate(),
exampleTable.getMaxRowCount()
Does anyone know why this isn't working or any help? Futhermore the % if anyone is wondering is just used for requesting everything related to that value. Thanks.
答案1
得分: 0
检查一下你的数据库字段类型/大小是否支持你尝试放入其中的数据长度。
也许那个无法工作的数据库与其他三个能工作的数据库之间存在轻微的模式差异。
假设 yourdb.exampleTable.site
字段是 VARCHAR(10)
,而 exampleTable.getSite()
返回的是 "my-site-name-is-more-than-10-chars-long"
,这将导致抛出 java.sql.DataTruncation
异常。
英文翻译
Check if your dbs' fields type/size support the data length you are trying to put into it.
Maybe there is a slight schema difference between the three DBs that work and the one that doesn't.
Let's say yourdb.exampleTable.site
field is a VARCHAR(10)
and exampleTable.getSite()
is "my-site-name-is-more-than-10-chars-long"
, that would cause this java.sql.DataTruncation
exception to be thrown.
专注分享java语言的经验与见解,让所有开发者获益!
评论