| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package UIB.UIB03.ZBS;
- import java.io.OutputStream;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import CoreFS.SA01.CoreIComponent;
- import UIB.COM.XmlSqlParsersFactory;
- import oracle.sql.BLOB;
- /**
- *
- * @desc
- * @author meiguiping
- * @date 2010 11:24:56 PM
- */
- public class BlobOutputStream extends CoreIComponent
- {
-
- public BlobOutputStream(){}
-
- public BLOB getBLob(String sql ,String blobName , String param) throws Exception
- {
- Connection con = null;
- PreparedStatement pstm = null;
- BLOB blob = null;
- try
- {
- con = this.getDao("KgDao").getConnection();
- pstm = con.prepareStatement(XmlSqlParsersFactory.getSql(sql));
- pstm.setString(1, param);
- ResultSet rs = pstm.executeQuery();
-
- if(rs.next())
- {
- blob = (oracle.sql.BLOB)rs.getBlob(blobName);
- // blob.close();
- }
- }catch(Exception ex)
- {
- throw new Exception("获取BLOB对象异常!");
- }
- finally
- {
- try
- {
- // if(pstm !=null)
- // pstm.close();
- if(con != null)
- con.close();
- }catch(Exception e)
- {
- throw new Exception("数据库连接异常!");
- }
- }
- return blob;
- }
-
- public OutputStream getOutputStream(String sql ,String blobName, String param)throws Exception
- {
- OutputStream os = getBLob(sql ,blobName, param).getBinaryOutputStream();
- // os.close();
- return os;
- }
-
- }
|