请问,如何处理oracle long raw字段类型

esunshine 2009-12-29 09:51:44
使用ByteArrayInputStream读取后,再插入到表内,很是吃内存,大家有好的方法,不吃内存的。谢谢。
...全文
98 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
esunshine 2009-12-30
  • 打赏
  • 举报
回复
这个long raw 值大的话,就出错了。
crazylaa 2009-12-30
  • 打赏
  • 举报
回复
关于用java存取oracle的long raw类型数据
public static void insertRaw() {
Connection conn=null;
PreparedStatement stmt=null;
Statement stat=null;
String sqlQuery="select name,longraw from test1";
try {
conn=getConnection();
if (conn==null) return;
conn.setAutoCommit(false);
stat=conn.createStatement();
ResultSet rs=stat.executeQuery(sqlQuery);
while (rs.next()) {
String name=rs.getString(1);
byte[] longraw=rs.getBytes(2);
stmt=conn.prepareStatement("insert into test2 values(?,?)");
stmt.setString(1,name);
stmt.setBytes(2,longraw);
stmt.execute();
}
conn.commit();

}catch(SQLException e) {
try {
conn.rollback();
}catch(SQLException re){}
e.printStackTrace();
}finally {
try {
stmt.close();
conn.close();
stat.close();
}catch(SQLException ie){}
}
}

create table TEST1
(
NAME VARCHAR2(20) not null,
LONGRAW LONG RAW
)
test2和test1一样,
这是个例程,我在oracle 9i上运行正常,你根据你自己的表结构改改吧

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧