数据库大数据BLOB类型转换文本

来源:互联网 发布:js 设置radio被选中 编辑:程序博客网 时间:2024/04/30 15:44

jsp解析HTML   <tr><td><s:propertyvalue="content" escape="false" /></td></tr>

        <!--<tr><td>${content}</td></tr>-->

数据库大数据BLOB类型转换文本

        DBSys dbsys = newDBSys();

        StringstrSQL="select t.id,t.title,t.content,t.newsimage fromtf_health_information t " +

               "where t.is_deleted=0";

        try{

        ResultSet rs =dbsys.getConnection().createStatement().executeQuery(strSQL);

        int i=0;

        while (rs.next()){

               oracle.sql.BLOB blob = (oracle.sql.BLOB)rs.getBlob("content");

               java.io.InputStream in = blob.getBinaryStream();

               ByteArrayOutputStream outStream = new ByteArrayOutputStream(); 

                byte[]data = new byte[4096]; 

                int count= -1; 

               while((count = in.read(data,0,4096)) != -1) 

                    {

                       outStream.write(data, 0, count); 

                    }

              data =null; 

             System.out.println("-----------------"+i+++"-----------------"+newString(outStream.toByteArray(),"GBK")); 

        }

        }catch(Exceptione)

        {

           e.printStackTrace();

        }

原创粉丝点击