从ORACLE数据库下载文件的问题???急~
我用以下代码下载,过程没有报错
但是下载下来的东西 总是86字节,而且打开以后里面总是乱码 这是为什么呢?
请大家帮忙..谢谢了
Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();
String url= "jdbc:oracle:thin:@192.168.31.109:1521:iasdb ";
//orcl为你的数据库的SID
String user= "news ";
String password= "up722006 ";
String name= "xxx ";
Connection conn = DriverManager.getConnection(url,user,password);
PreparedStatement st=conn.prepareStatement( "select up_file from test where name=? " );
st.setString(1,name);
//ResultSet rs =st.executeQuery();
ResultSet rs=st.executeQuery();
if (rs.next())
{
byte[] cnt=rs.getBytes( "up_file ");
System.out.print( "here ");
response.getOutputStream().write(cnt);
System.out.print( "hehe ");
}
}
------解决方案--------------------文件是不是二进制的?这样的话遇到0就结束了吧。
------解决方案--------------------mstrBackName = result.getString( "randomname ");
mstrfileName = result.getString( "markname ");
pintid = result.getInt( "id ");
InputStream inStream=result.getBinaryStream( "MarkBody ");
String aa=getServletContext().getRealPath( "/ ")+ "upload/showFile/ ";
FileOutputStream fs=new FileOutputStream(aa+mstrBackName);
if(mstrBackName!=null&&mstrBackName!= " ")
{
byte[] buffer =new byte[1444];
while ((int byteread=inStream.read(buffer))!=-1)
{
fs.write(buffer,0,byteread);
}
}
你根据这个把你的改一改试试