【发布时间】:2015-05-19 00:37:15
【问题描述】:
使用 tomcat 和 mysql 在 webapps 中处理 clob 似乎很容易。 对于下面的示例,我们假设我们有一个表 'mytable',其中包含一个 clob 'myclob' 和一个键 'id' 这是一个如何将字节数组放入 clob 的示例:
Connection conn = null;
PreparedStatement stmt = null;
ByteArrayInputStream bis = null;
try {
if (mydatasource != null)
conn = mydatasource.getConnection();
StringBuffer sb=new StringBuffer("update mytable set myclob = ? where id = ?");
bis=new ByteArrayInputStream(myArrayOfBytes);
stmt.setBinaryStream( 1, bis);
stmt.setString(2, "myId");
stmt.executeUpdate();
} catch(Exception ex){
ex.printStackTrace();
} finally {
try{bis.close();} catch (Exception x) {;}
try{stmt.close();} catch (Exception x) {;}
try{conn.close();} catch (Exception x) {;}
}
当我尝试将我的 webapp 移动到 jboss 5.0 和 Oracle db 时,困难在于:
ORA-01461: 只能绑定 LONG 值以插入到 LONG 列中
问题是:如何解决这个错误(还认为方法'createClob()'不起作用?
【问题讨论】:
-
你的问题是什么?