cancel
Showing results for 
Search instead for 
Did you mean: 

Read Blob-Values by JDBC-Lookup

thorsten_hautz
Participant
0 Kudos

Hi,

we have to read the original message format of a message in the mapping step from the adapter database.

This original message was stored as BLOB-value there.

When we try to read the value via an accelerator object we get the following Java-Exception:

com.sap.aii.mapping.lookup.LookupException: 
Plain exception:oracle.jdbc.driver.T4CConnection java.io.NotSerializableException: 
oracle.jdbc.driver.T4CConnection at java.io.ObjectOutputStream.writeObject0
(ObjectOutputStream.java:1054)

Here an extraction of our source code:

...
Channel channel = null;
		
DataBaseAccessor accessor = null;
DataBaseResult rset = null;
		
Map rowMap = null;
							 	
try {
			
  String sapName = GlobalProperties.getSapSystemName();

  channel = LookupService.getChannel(sapName, "CC_DBLookup");
  accessor = LookupService.getDataBaseAccessor(channel);

  ...

  String sqlQuery = "select MSG_BYTES "+ 
	 "from "+oracleDB+".XI_AF_MSG "+					  
	"where MSG_ID = '"+msgID+"'";
	
	
  accessor.execute(sqlQuery);
  ...

When we try to read a value of another type it works fine.

Does anybody know how we can solve this problem?

Regards

Thorsten

Edited by: Thorsten Hautz on Nov 13, 2008 8:21 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Thorsten,

It could be driver related, but Iu2019m really not sure. Perhaps someone else will have more information. I did run a quick test to see if BLOB was serilaziable. Using classes12.zip in the classpath caused the code below to fail with a similar exception to the one you showed:


java.io.NotSerializableException: oracle.sql.BLOB
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
	at test.BlobTeset.main(BlobTeset.java:20)

Using a newer driver (classes12_10.2.0.2.jar) and the same code works . Again, this may or may not be related, but you might at least check your driver versions.


package test;

import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;

public class BlobTeset {

	public static void main(String[] args) {
		try {

			// Old driver (classes12.zip) throws java.io.NotSerializableException
			// New driver (classes12_10.2.0.2.jar) doesn't
						
			oracle.sql.BLOB blob = oracle.sql.BLOB.empty_lob(); //deprecated (getEmptyBLOB)
			blob.setBytes("Testing".getBytes());

			// Serializeable
			ByteArrayOutputStream bos = new ByteArrayOutputStream() ;
			ObjectOutputStream out = new ObjectOutputStream(bos) ;
			out.writeObject(blob);
			out.close();

			System.out.println("Done");

		} catch (Exception e) {
			e.printStackTrace();
		}		
	}
}

If the driver isnu2019t the issue, and if no one else has additional information, you may need to get a connection directly from a JDBC connection pool. Check out this blog. It will help you get the connection via a data source. https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/6183

From there, you should be able to find code samples for working directly with the BLOB.

-Russ

Answers (2)

Answers (2)

thorsten_hautz
Participant
0 Kudos

Hi,

thanks for all your answers.

We have soved the problem by using a DataSource.

Regards

Thorsten

Former Member
0 Kudos

Hi

Its a JDBC driver issue. Which oracle you are using is it 9i? Update the driver with PI to sort this

Thanks

Gaurav