how to store blob object in document variable

204 views
Skip to first unread message

Kripa

unread,
Mar 19, 2009, 2:28:16 AM3/19/09
to Adobe LiveCycle Developers
hi,
I am using Query single row service to retrieve pdf file from database
(it is stored as blob in database). How can i store this blob object
in a document variable? I am using oracle database.
I gave the mapping in "Data Mapping" property of the service. I mapped
the column name with a document variable. It gave the following
error:

com.adobe.workflow.datatype.InvalidCoercionException: Cannot coerce
object: weblogic.jdbc.wrapper.Blob_oracle_sql_BLOB@832ef of type:
weblogic.jdbc.wrapper.Blob_oracle_sql_BLOB to type:
com.adobe.idp.Document.

can anyone help me in this? Can i store the blob object retrieved from
database in any other form in my process?

Thanks.
kripa

JYates

unread,
Mar 20, 2009, 11:24:23 AM3/20/09
to Adobe LiveCycle Developers
You can do this, but you have to use the Execute Script service -- at
this time there isn't a deployable component for it.

Use this sort of script in the Execute Script service to read the PDF
blob from the database and populate a Document variable.

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.sql.DataSource;
import javax.naming.InitialContext;

int processId = patExecContext.getProcessDataIntValue("/process_data/
@id");

InitialContext context = new InitialContext();
Connection connection = ((DataSource)context.lookup("java:/
IDP_DS")).getConnection();

String queryQuery = "select bigdocument, bigstring from
tb_pt_workwithxlobs where
process_instance_id = ?";
PreparedStatement queryStatement = connection.prepareStatement
(queryQuery);

try {
queryStatement.setInt(1, processId);
ResultSet results = queryStatement.executeQuery();
results.next();

java.sql.Blob documentBlob = results.getBlob(1);
com.adobe.idp.Document document = new
com.adobe.idp.Document(documentBlob.getBinaryStream());
patExecContext.setProcessDataValue("/process_data/@NewBigDocument",
document);

java.sql.Clob stringClob = results.getClob(2);
patExecContext.setProcessDataValue("/process_data/@NewBigString",
stringClob.getSubString(1L,
(int)stringClob.length()));
} catch(Exception ex) {
ex.printStackTrace();
}

queryStatement.close();
connection.close();

JYates
Avoka Technologies

Selva

unread,
Mar 31, 2009, 8:56:59 AM3/31/09
to Adobe LiveCycle Developers
Hi JYates,

Thanks a lot for your help. Your script helped me out to solve the
issue.

Regards,
kripa
> > kripa- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages