¿BLOB de la base de datos de Oracle a InputStream en Java?

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?

preguntado el 08 de noviembre de 11 a las 11:11

2 Respuestas

You haven't really said how you're fetching data from the database, but you can use ResultSet.getBinaryStream() para obtener una InputStream, O llame al getBlob() conseguir un Blob, y entonces getBinaryStream() al Blob to get a stream.

respondido 08 nov., 11:15

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 - Base de datos

@Data-Base: I meant which client technology you were using - an ORM such as Hibernate, direct JDBC, which driver etc. - Jon Skeet

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 - Base de datos

@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... - Jon Skeet

Declare your Java parameter of type oracle.sql.BLOB según el "Mapping Datatypes" documentation. Entonces, llamas getBinaryStream() en ese BLOB object to obtain your InputStream.

respondido 08 nov., 11:18

and then? how do I convert it to InputStream? - Base de datos

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.