java 下载 Oracel BOLB文件 现在得到oracle数据库的一个BLOB,这个BLOB是一个上传的文件,现在我能得到这个byte[],如何下载?java代码里边如何写?求指点思路...这个byte[]是整个文件,如何用outputstream把它下载下来? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public void query()throws Exception { Connection conn=null; PreparedStatement pst=null; ResultSet rs=null; try { conn=TextJdbc.newInstance().getConnection(); pst=conn.prepareStatement("select id,name,picontext from pic"); rs=pst.executeQuery(); while(rs.next()) { int pid=rs.getInt(1); String name=rs.getString(2); java.sql.Blob blob=rs.getBlob(3); int len=(int)blob.length(); byte b[]=blob.getBytes(1, len); writer(b,name); System.out.println(pid+"\t"+name); } } finally { TextJdbc.newInstance().close(rs, pst, conn); } } public void writer(byte[] b,String name)throws Exception { FileOutputStream fos=null; try { fos=new FileOutputStream("d:\\ywx\\"+name+".jpg"); fos.write(b); } finally { fos.close(); } }不知道是否符合你的要求。 项目合并问题 如何把U盘里面的数据显示在浏览器里面。 求一解决方案,如图 同一台机器上运行两个tomcat的问题 一般 接收 参数 用哪种 方法 的 ? 用SPING框架有什么好处??? 求hibernate3.2+oracle9i的简单实例?只需要能访问到数据库就行. 请教一个再在Servlet中设置文件相对路径的问题!急!!! 结交写jsp的朋友,跟贴有分! Servlet生成文件时,如何使该文件的格式被识别,如何控制下载的名字 struts2检验文件不起作用 有关DSEE问题
{
Connection conn=null;
PreparedStatement pst=null;
ResultSet rs=null;
try
{
conn=TextJdbc.newInstance().getConnection();
pst=conn.prepareStatement("select id,name,picontext from pic");
rs=pst.executeQuery();
while(rs.next())
{
int pid=rs.getInt(1);
String name=rs.getString(2);
java.sql.Blob blob=rs.getBlob(3);
int len=(int)blob.length();
byte b[]=blob.getBytes(1, len);
writer(b,name);
System.out.println(pid+"\t"+name);
}
}
finally
{
TextJdbc.newInstance().close(rs, pst, conn);
}
}
public void writer(byte[] b,String name)throws Exception
{
FileOutputStream fos=null;
try
{
fos=new FileOutputStream("d:\\ywx\\"+name+".jpg");
fos.write(b);
}
finally
{
fos.close();
}
}不知道是否符合你的要求。