tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thangamani, Elanjchezhiyan (Cognizant)" <TEl...@chn.Cognizant.com>
Subject Problem in inserting word document into database as a blob object under tomcat server
Date Tue, 08 Jun 2004 04:10:53 GMT

> Hi,
> I am inserting word document into database as a blob. It is inserting successfully but
we try to download it is not downloading. The insertion itself having some problem
>
> //code listed below
>
> StringBuffer query = new StringBuffer("Insert into PMS_Documents(DOCUMENTID, DOCUMENT_NAME,
DOCUMENT_TYPE_ID, DOCUMENT_DESCRIPTION, DOCUMENT_CTYPE,CREATED_BY, CREATED_DATE,DOCUMENT_BLOB)
values(");
> pmskey =getSequence("Document.nextval");
> query.append(pmskey);
> query.append(",'");
> query.append(form.getDocumentName());
> query.append("',");
> query.append(Integer.parseInt(getLookUPId("document", form.getDocumentType())));
> query.append(",'");
> query.append(form.getDocumentDescription().trim());
> query.append("','");
> query.append(form.getDocumentBlob().getContentType());
> query.append("','");
> query.append(form.getDocumentCreatedBy());
> query.append("',sysdate,EMPTY_BLOB())");
> query.toString();
> .................................
> conn = getConnection();
> conn.setAutoCommit(false);
> stat = conn.createStatement();
> stat.execute(query);
> stat.execute("commit");
> String SQL_GET_BY_PK ="select document_blob from PMS_Documents where documentId="+ pmskey
+" for update nowait" ;
> rs = stat.executeQuery(SQL_GET_BY_PK);
> rs.next();
> ResourceBundle resBun = ResourceBundle.getBundle("pms");
> String server = resBun.getString("server");
> if (server.equals("tomcat")) {
> dbBlob = (oracle.sql.BLOB)rs.getBlob(1); //problem occurs here only
> }
> else {
> weblogic.jdbc.rmi.SerialOracleBlob cast1 = (weblogic.jdbc.rmi.SerialOracleBlob)rs.getBlob(1);
> weblogic.jdbc.rmi.internal.OracleTBlobImpl cast2 = (weblogic.jdbc.rmi.internal.OracleTBlobImpl)cast1.getTheRealBlob();
> dbBlob = (oracle.sql.BLOB)cast2.getTheRealBlob();
> }
> inStream = new BufferedInputStream(form.getDocumentBlob().getInputStream());
> //createDocument(inStream);
> outStream = dbBlob.getBinaryOutputStream();
> while((len = inStream.read()) != -1) {
> outStream.write(len);
> fileSize += len;
> }
> if(inStream != null) {
> inStream.close();
> inStream = null;
> }
> if(outStream != null) {
> outStream.close();
> outStream = null;
> }
>
> I am getting problem in tomcat only . weblogic it is working fine.
>
> Thanks in Advance
> Elan
> 


This e-mail and any files transmitted with it are for the sole use of the intended recipient(s)
and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and destroy
all copies of the original message.
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or copying of
this email or any action taken in reliance on this e-mail is strictly
prohibited and may be unlawful.

  Visit us at http://www.cognizant.com
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message