高分求解!(jsp中怎样保存图片文件到oracle数据库,求原代码)!! http://community.csdn.net/Expert/topic/2984/2984158.xml?temp=.7139093 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以用blob大对象来进行存储.java端可以这样处理:我这里是基于weblogic连接池的情况下:用Class.forName()方式会有点区别.大小差异不大.public java.io.ByteArrayOutputStream readFileFromDB(int index,String ifwhere){ InputStream is=null; int bytesread=0; byte []butter=new byte[8*1024]; java.io.ByteArrayOutputStream bos=null; String sql=""; java.sql.Blob blob = null; sql=sqlblob[index]+ifwhere; System.out.println(sql); System.out.println(sql); try{ //Initialization ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); //Get Connection con = new DBconn().getConnection(); pst = con.prepareStatement(sql); rs = pst.executeQuery(); int size = 0; while (rs.next()) { //Get Blob blob = rs.getBlob(1); if(blob.length()!=0) is = blob.getBinaryStream(); } while(((bytesread=is.read())!=-1)){ bos.write(bytesread); } }catch (Exception e) { System.out.println(e.toString()); }finally { try { if (rs != null) rs.close(); if (pst != null) pst.close(); if (con != null) con.close(); } catch (Exception e) { System.out.println("数据库连接错误:"+e.toString()); } } return bos; } 关于oracle 临时表与游标的问题?? 怎么写sql语句,按字段fld1分组,求组合值 请问oracle监听服务无法打开是什么原因??? connect by prior的问题! 索引高手看看吧 两表联查,排序多个字段 关于触发器的问题 想在插入一条记录的同时修改该记录中的某一字段 有关分组查询时 KEEP 的使用? 用户没有create或delete操作系统权限如何实现??? Oracle中,取某个字段的某些字符! 大GG大JJ这边看过来:怎么样能同时向一个表里面插入多条记录呢?谢谢:) 求教:Insert into中使用子查询出错,何解?
java端可以这样处理:
我这里是基于weblogic连接池的情况下:
用Class.forName()方式会有点区别.大小差异不大.public java.io.ByteArrayOutputStream readFileFromDB(int index,String ifwhere){ InputStream is=null;
int bytesread=0;
byte []butter=new byte[8*1024];
java.io.ByteArrayOutputStream bos=null;
String sql="";
java.sql.Blob blob = null;
sql=sqlblob[index]+ifwhere;
System.out.println(sql); System.out.println(sql);
try{ //Initialization ByteArrayOutputStream
bos = new java.io.ByteArrayOutputStream(); //Get Connection
con = new DBconn().getConnection(); pst = con.prepareStatement(sql);
rs = pst.executeQuery();
int size = 0;
while (rs.next()) { //Get Blob
blob = rs.getBlob(1);
if(blob.length()!=0)
is = blob.getBinaryStream();
} while(((bytesread=is.read())!=-1)){
bos.write(bytesread);
} }catch (Exception e) {
System.out.println(e.toString());
}finally {
try {
if (rs != null)
rs.close();
if (pst != null)
pst.close();
if (con != null)
con.close(); }
catch (Exception e) {
System.out.println("数据库连接错误:"+e.toString());
}
}
return bos;
}