tags:

views:

250

answers:

2

Im looking por any kind of procedure that let me save a Java.io.file in an oracle directory, it may be a stored procedure or a java stored or somethig beyond... if somebody has any example of this, ill thank it forever. im in my web app and i need to store some uploaded files in a specific directory /home/oracle/oracle/.../mydirectory, almost every post is about saving to a table. I need specifically save it to a directory. please somebody help me!!!.

The point is i need to save an uploaded file from my web app to an oracle directory i was trying to pass the file as parameter to a stored procedure, but i dont even know what data type is compatible to pass the file as parameter ... ex: my_stroredprcedure(location IN VARCHAR2, theFile IN DATATYPE)...

and so on...

+1  A: 

Hi Aktheus,

You wouldn't necessarily need to use Oracle libraries to store the file. You would query the location of the Oracle Directory from the data dictionary (if you need to), i.e.

SELECT directory_name FROM user_directories;

Then you would use standard Java IO libraries to write the file to that directory, assuming you have access to it, and remembering that the path is relevant to the database server.

What kind of file do you want to store? Is there any need to use the DBMS for this task at all? You can use UTL_FILE to write to an Oracle directory from a stored procedure if you need to.

In order to properly answer your question, we need to know a bit more about what you're trying to do.

idea
Im sorry but i dont get it, from my web app, i´ll execute the query you told me above, and what do i expect to recieve a path? and later in mi class instance a new File x = new File(path_returned_from_query)?? sorry i don´t know more than the basics. If you don´t mind will you explain it with an example.
Aktheus
Okay, if you are writing to a file to a directory, why do you need to use the Oracle Database to do this? The query I gave would return the path of the Oracle Directory object. For example: The path to an Oracle Directory with the name "AUDIT_DIR" could be returned with:SELECT directory_pathFROM all_directoriesWHERE directory_name = 'AUDIT_DIR';The reason I ask: This is a much more trivial task to perform using straight Java. If you need to use Oracle, you should google Oracle BLOBs (binary large objects), which JDBC drivers support- I couldn't provide an example off the top of my head.
idea
A: 

Check my answer to your other question on this topic.

APC