4

I made a Java function that takes an InputStream as an input. I have a oracle.sql.BLOB instance to pass to that function. How can I convert it to a InputStream?

Do I need to re-write my function using a BLOB parameter, instead?

0

2 Answers 2

7

You haven't really said how you're fetching data from the database, but you can use ResultSet.getBinaryStream() to get an InputStream, or call getBlob() to get a Blob, and then getBinaryStream() on the Blob to get a stream.

Sign up to request clarification or add additional context in comments.

4 Comments

we fatch it with PL/SQL so nothing special here, where there is a PL/SQL function that call the java function and return the results
@Data-Base: I meant which client technology you were using - an ORM such as Hibernate, direct JDBC, which driver etc.
not sure what do you mean but none! we just query the database from the PL/SQL and send the variable to the function the function take the variable convert the data and return a text the Java is compiled as class inside the Oracle Database
@Data-Base: Ah - that's a different matter then. It's relatively rare to come across Java code running in the database... I wish you'd said that to start with, as I've no idea how that works. Basically look for Blob-related calls in whatever API you've got...
6

Declare your Java parameter of type oracle.sql.BLOB as per the "Mapping Datatypes" documentation. Then, you call getBinaryStream() on that BLOB object to obtain your InputStream.

1 Comment

and then? how do I convert it to InputStream?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.