[code=Java][Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try{
con = ConnectionFactory.getConnection();
con.setAutoCommit(false);
String sql = "insert into images(id,name,image) values(?,?,empty_blob())";
ps = con.prepareStatement(sql);
ps.setLong(1, id);
ps.setString(2, imagename);
ps.executeUpdate();
ps.close();
sql = "select image from images where id=? for update";
ps = con.prepareStatement(sql);
ps.setLong(1, id);
rs = ps.executeQuery();
while(rs.next()){
Blob image = (Blob)rs.getBlob("image");//找到要写入的位置
OutputStream out = image.setBinaryStream(0); //得到输入流,并指定开始读入的位置
BufferedOutputStream bos = new BufferedOutputStream(out);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(path));
int c ;
while((c=bis.read())!=-1){
bos.write(c);
}
bis.close();
bos.close();
}
con.commit();/code]
我的这段代码有什么问题,怎么画线的地方老是报Exception in thread "main" java.lang.AbstractMethodError: oracle.sql.BLOB.setBinaryStream(J)Ljava/io/OutputStream;异常
PreparedStatement ps = null;
ResultSet rs = null;
try{
con = ConnectionFactory.getConnection();
con.setAutoCommit(false);
String sql = "insert into images(id,name,image) values(?,?,empty_blob())";
ps = con.prepareStatement(sql);
ps.setLong(1, id);
ps.setString(2, imagename);
ps.executeUpdate();
ps.close();
sql = "select image from images where id=? for update";
ps = con.prepareStatement(sql);
ps.setLong(1, id);
rs = ps.executeQuery();
while(rs.next()){
Blob image = (Blob)rs.getBlob("image");//找到要写入的位置
OutputStream out = image.setBinaryStream(0); //得到输入流,并指定开始读入的位置
BufferedOutputStream bos = new BufferedOutputStream(out);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(path));
int c ;
while((c=bis.read())!=-1){
bos.write(c);
}
bis.close();
bos.close();
}
con.commit();/code]
我的这段代码有什么问题,怎么画线的地方老是报Exception in thread "main" java.lang.AbstractMethodError: oracle.sql.BLOB.setBinaryStream(J)Ljava/io/OutputStream;异常
解决方案 »
- 求助:form开发,enter_query相关
- 各位大大,我在odbc数据源连接后test connect时发生这样的报错该怎么办???谁能帮帮忙?
- oracle菜鸟问题
- 初学者问题:请问在oracle9i中如何建库和表
- A granule is a unit of contiguous virtual memory allocation中的granule及contiguous的意思?
- 关于树形查找的SQL语句问题:
- 散分,欢迎大家来讨论!
- pl/sql高手请指教!这样简单的过程函数为什么就不行呢?
- 存储过程中如何返回几个值。不能通过out参数
- 从其他表抽取数据插入一张表的SQL
- 急聘:.NET程序员/软件项目经理
- 如何使用触发器修改插入的新值???
import java.sql.Blob;
没有用oracle.sql.BLOB
还有就是不要用导入java.sql.blob这个包,而是要导入oracle.sql.BLOB,这样就可以完成了