Bind 主机变量的长度超过 MaxLength
我遇到了 Sybase IQ 服务器抛出的神秘错误消息。
com.sybase.jdbc2.jdbc.SybSQLException:ASA 错误 -1001019:函数 不支持长度超过 255 的 varchar 绑定主变量长度 超过最大长度, --(df_Heap.cxx 2145) 在 com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2636) 在 com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1996) 在 com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69) 在 com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:204) 在 com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:187) 在 com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1642) 在 com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1625) 在 com.sybase.jdbc2.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:91) 在 ibs.dao.CM3RM1DAO.updateToTable(CM3RM1DAO.java:197) 在 ibs.dao.CM3RM1DAO.isXMLProcessed(CM3RM1DAO.java:88) 在 ibs.xml.parser.XMLParser.parsingXMLIntoBO(XMLParser.java:2125) 在 ibs.common.util.MainClass.main(MainClass.java:74)
我们有几个类型为 varchar(4000)
的列(DESCRIPTION
等)。不过我可以直接更新它们而不会出现任何错误。而且,我没有看到任何指定任何绑定变量的代码,所以我不知道消息来自哪里。
这是代码(我对其进行了一些修改):
String sql = "UPDATE TABLEX SET " +
"COMPANY = ?, CUSTOMER_REFERENCE= ?, " +
"STATUS = ?, CONTACT_FIRST_NAME = ?, CONTACT_LAST_NAME = ?, " +
"SEVERITY = ?, PRIORITY_CODE = ?, REQUESTEDDATE = ?, " +
"CLOSE_TIME = ?, LEAD_TIME = ?, CHANGE_REASON = ?, MODTIME = ? WHERE NUMBER = ?";
stmt = conn.prepareStatement(sql);
for loop here
{
stmt.setString(...);
.
.
stmt.executeUpdate();
}
感谢任何帮助
I've encountered a cryptic error message thrown by Sybase IQ server.
com.sybase.jdbc2.jdbc.SybSQLException: ASA Error -1001019: Function
not supported on varchars longer than 255 Length of Bind host variable
exceeds MaxLength ,
-- (df_Heap.cxx 2145)
at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2636)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1996)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:204)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:187)
at com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1642)
at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1625)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:91)
at ibs.dao.CM3RM1DAO.updateToTable(CM3RM1DAO.java:197)
at ibs.dao.CM3RM1DAO.isXMLProcessed(CM3RM1DAO.java:88)
at ibs.xml.parser.XMLParser.parsingXMLIntoBO(XMLParser.java:2125)
at ibs.common.util.MainClass.main(MainClass.java:74)
We have several columns (DESCRIPTION
etc.) which are of type varchar(4000)
. However I can update them directly without having any error. And, I don't see any code specifying any bind variables, so I have no idea where the message comes from.
This is the code (I've modified it a bit):
String sql = "UPDATE TABLEX SET " +
"COMPANY = ?, CUSTOMER_REFERENCE= ?, " +
"STATUS = ?, CONTACT_FIRST_NAME = ?, CONTACT_LAST_NAME = ?, " +
"SEVERITY = ?, PRIORITY_CODE = ?, REQUESTEDDATE = ?, " +
"CLOSE_TIME = ?, LEAD_TIME = ?, CHANGE_REASON = ?, MODTIME = ? WHERE NUMBER = ?";
stmt = conn.prepareStatement(sql);
for loop here
{
stmt.setString(...);
.
.
stmt.executeUpdate();
}
Any help is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问号是绑定变量。您的 stmt.set...(...) 语句之一尝试设置一个比数据库列允许的长度更长的值。尝试显示您正在设置的每个 Java 字符串的长度。
The question marks are bind variables. One of your
stmt.set...(...)
statements is trying to set a value longer than the database column will allow. Try displaying the length of each Java String that you are setting.最后我能够使用客户发送的示例数据重现该错误。
其中一个字段的数据类型是 VarChar(4000)。然而,用户试图用 32k 个字符的数据更新此字段!
一旦我截断数据,数据就成功更新了。
我以为 Sybase 会自动截断数据,但显然事实并非如此。
Finally I was able to reproduce the error with the sample data sent by customer.
Data type of one of the fields was VarChar(4000). However the user was trying to update this field with data which has 32k characters!
Once I truncate the data, the data was updated successfully.
I thought Sybase automatically truncate the data, but apparently it doesn't.