[英]Store byte[] in BLOB Oracle
我正在執行以下操作將其插入BLOB Oracle 11g。
圖像采用Base64編碼,存儲在從XML提取的字符串中。
String str = "xyz...."
byte[] bytes = str.getBytes();
InputStream is = new ByteArrayInputStream(bytes);
PreparedStatement prepStmt = dbCon.prepareStatement("insert into Table(INDEX,RESPONSE_IMAGE) values(?,?);
prepStmt.setString(1, action.getIndex());
prepStmt.setBinaryStream(2, is, str.length());
我認為問題是圖像的字節長度,因為當我獲得String的length()時,它約為200,000個字節 。
當我在String上執行subString(3000)時, 它很容易保存在BLOB列中 。
所以問題實際上在哪里?
我讀到BLOB最多可以保存4GB數據,那為什么我的呢?
這里是有關將Blob與JDBC結合使用的Oracle教程。
相關部分:
Clob myClob = this.con.createClob();
Writer clobWriter = myClob.setCharacterStream(1);
和...一起:
添加和檢索BLOB SQL對象類似於添加和檢索CLOB SQL對象。 使用Blob.setBinaryStream方法檢索OutputStream對象,以寫入Blob Java對象(稱為方法)表示的BLOB SQL值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.