尝试将大小为 2MB 的文件存储为 BLOB 数据时,数据库抛出异常 [英] Database is throwing exception while trying to store a file of size 2MB as a BLOB data
问题描述
在我的一个应用程序中,我尝试使用 JDBC 连接将一个文件(文件大小为 2MB)作为 BLOB 数据保存到 teradata 数据库表中.但是每次我都会遇到一个如下异常
In one of my application i was trying to save one file (Size of the file is 2MB) in to the teradata database table as a BLOB data by using JDBC connection. But everytime i was getting one exception which is as follows
com.teradata.jdbc.jdbc_4.util.JDBCException: [Teradata JDBC Driver] [TeraJDBC 14.00.00.01] [错误 1186] [SQLState HY000] 参数 2 长度为 2215538 字节,大于最大值可设置 64000 字节.
请帮我解决这个问题.
谢谢,苏拉夫
推荐答案
假设你有 String 格式的数据,我们可以使用 setCharacterStream 绕过 64000 字节的限制.
Assuming you have data in String format we can use setCharacterStream to bypass the restriction of 64000 bytes.
使用preparedStatement插入大量数据clob列
Using preparedStatement to insert large amount of data clob column as
pStmt.setCharacterStream(paramterIndex, new StringReader(StringToBeInserted), StringToBeInserted.length());
这篇关于尝试将大小为 2MB 的文件存储为 BLOB 数据时,数据库抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!