Accessing files in directory using Java SP in 10g
Hi all-
I have set up a directory in 10g which points to an existing directory in the operating system and am trying to get the list of files in it from a Java stored procedure. The directory in Oracle is called "Upload_to_Oracle" and am trying to get the files in the sp by calling:
File f1=new File("Upload_To_Oracle");
File fs[] =f1.listFiles();
System.out.println("The count of files is " + fs.length);
The problem is fs is null, so fs.length causes an exception to be thrown. Initially I was getting an error:
the Permission (java.io.FilePermission Upload_To_Oracle read) has not been granted to ILFORD. The PL/SQL to grant this is dbms_java.grant_permission('ILFORD', 'SYS:java.io.FilePermission', 'Upload_To_Oracle', 'read')
which I (think) I resolved by executing that command as SYS (this is a dev box used by just me) and logging out of sqlplus and back in.
I haven't been able to find anywhere how you're supposed to reference an Oracle directory in Java, so in all honesty, I don't know if this is how you're supposed to do it.
Any help would be appreciated.
Thanks,
Ilford
I figured it out for anyone who needs something similar; the problem is that the Oracle directory is specific to particular files that Oracle will use for loading (BFiles, etc.). To get at the file system directory, I just needed to reference the actual system directory itself, as well as grant it permission.
So what it comes down to is that you should reference the directory in File() as if it truly were a regular Java app on the filesystem, making sure the appropriate permissions are set for both the user running Oracle (for file/directory access) as well as for Java access.
Similar Messages
-
Creating aVirtual directory Using java
Hai ,
I am Using windows XP Operating system, I know how to create a directory using java,
can you please suggest me a procedure to create a virtual(web share ) directory using java.
waiting for your reply
Thanks & Regards,
Naga RajuVirtual Programmer is in the to share the directory
over the Internet.No, that's a file/web server. :) I see, it's a Microsoft term. -
How to trace changes in directories and files in windows using java.
Hi,
Want to know how to trace changes in directories and files in windows using java.
I need to create a java procedure that keeps track of any changes done in any directory and its files on a windows System and save this data.
Edited by: shruti.ggn on Mar 20, 2009 1:56 AMchk out the bellow list,get the xml and make the procedure.....
Notes
1 Some of the similar softwares include HoneyBow, honeytrap, honeyC, captureHPC, honeymole, captureBAT, nepenthes.
2 Some of the other hacking softwares include keyloggers. Keyloggers are used for monitoring the keystrokes typed by the user so that we can get the info or passwords one is typing. Some of the keyloggers include remote monitoring capability, it means that we can send the remote file across the network to someone else and then we can monitor the key strokes of that remote pc. Some of the famous keyloggers include win-spy, real-spy, family keylogger and stealth spy.
3 Apart from theses tools mentioned above there are some more tools to include that are deepfreeze, Elcomsoft password cracking tools, Online DFS, StegAlyzer, Log analysis tools such as sawmill, etc. -
File to JDBC using JAVA Mapping
Hello,
Can u explain me about the above scenario of File to JDBC using JAVA Mapping.
Iam new to XI explain above in detail.
*Points will be Rewarded*
Thanks&Regards,
RavichandKone.HI,
If your mapping is one to one then dont go for java mapping use graphical mapping.
/people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30 --> for jdbc receiver: file -JDBC
Here are the link which will help you in writing the stored procedure:
Receiver JDBC scenario MS access - /people/sameer.shadab/blog/2005/10/24/connecting-to-ms-access-using-receiver-jdbc-adapter-without-dsn
Stored Procedures-
/people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
http://www.ics.com/support/docs/dx/1.5/tut6.html
/people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
http://www.ics.com/support/docs/dx/1.5/tut6.html
http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html
http://www.sqlteam.com/article/stored-procedures-an-overview
thnx
Chirag Gohil -
Unzipping Files in Folder using Java
Hello,
I am working on a project and I am having trouble writing a program that will unzip all the files in a given directory (using Java). The directory is known, but the name and number of files to be unzipped will vary on each execution. The files need to be unzipped and then placed in a different specified folder.
Thank you for your assistance.This should give you some idea. Be sure to import java.util.zip.
/** unzipDirArchive */
public static void unzipDirArchive(File inFile)
throws IOException {
ZipEntry entry = null;
// Create stream to read the compressed file.
ZipInputStream zis = new ZipInputStream(new FileInputStream((inFile)));
// Create stream to write the output file.
FileOutputStream fos = null;
byte buffer[] = new byte[4096];
int bytesRead;
boolean dirCreated = false;
// For each entry in the ZIP input file.
while ((entry = zis.getNextEntry()) != null) {
// If we have not created the enclosing directory.
if (!dirCreated) {
// Create the directory.
int endIndex = entry.getName().lastIndexOf('/');
String dirName = entry.getName().substring(0, endIndex);
// DEBUG
// System.out.println("dirName is: " + dirName + ".");
File newDir = new File(dirName);
// Check if the output dir already exists.
if (newDir.exists()) {
System.err.println("Uncompress: Output directory " + dirName +
" already exists.");
System.exit(-5);
else {
// If we successfully created the enclosing directory.
if (newDir.mkdir()) {
dirCreated = true;
else {
System.err.println("Uncompress: Cannot create directory " +
dirName + ".");
System.exit(-6);
} // end if newDir.exists
} // end if !dirCreated
System.out.println("Inflating: " + entry.getName());
fos = new FileOutputStream(entry.getName());
// Copy the data from the ZIP file entry to a file.
while((bytesRead = zis.read(buffer)) != -1)
fos.write(buffer, 0, bytesRead);
fos.close();
} // end while more entries in the ZIP file
zis.close();
} // end method unzipDirArchive -
Moving files into directory using shell script
Can someone tell me how I move files into directory using *nix/linux shell script?
I have files which created from stored procedures using utl_file. The files name for example:
DKH_104_12345
DKE_101_42324242
DKH_102_32432
DKE_101_34553
Then I create directories automatically for example:
/oradata/apps/dmp/output/101
/oradata/apps/dmp/output/102
/oradata/apps/dmp/output/103
/oradata/apps/dmp/output/104
Using this procedure :
CREATE OR REPLACE PROCEDURE Xorganize AS
v_item VARCHAR2(5);
v_DirName VARCHAR2(50);
v_FileName VARCHAR2(50):='xorganize';
v_FileExt VARCHAR2(5):='.sh';
v_ID UTL_FILE.file_type;
CURSOR res IS
--find the directory name from table
SELECT brn_cde FROM vcr_brn_cde ORDER BY 1;
BEGIN
--used by utl.file funtion
SELECT PRD_DIR INTO v_DirName
FROM CR_SYS_PRM
WHERE CLT_CDE ='FIF';
SELECT v_FileName||v_FileExt INTO v_FileName FROM dual;
v_ID:=UTL_FILE.FOPEN(v_DirName,v_FileName, 'w');
utl_file.PUTF(v_ID,'%s\n','@@echo OFF');
utl_file.PUTF(v_ID,'%s\n','cls');
utl_file.PUTF(v_ID,'%s\n','echo Reorganizing ...');
OPEN res;
LOOP
FETCH res INTO v_item;
EXIT WHEN res%NOTFOUND;
utl_file.PUTF(v_ID,'%s\n','mkdir '||v_item);
END LOOP;
CLOSE res;
OPEN res;
LOOP
FETCH res INTO v_item;
EXIT WHEN res%NOTFOUND;
utl_file.PUTF(v_ID,'%s\n','move _'||v_item||'_.* '||v_item||'\');
END LOOP;
CLOSE res;
utl_file.PUTF(v_ID,'%s\n','FOR /F "usebackq delims=" %%1 IN (`dir /b *.`) DO @rd/q %%1');
utl_file.PUTF(v_ID,'%s\n','cls');
utl_file.PUTF(v_ID,'%s\n','echo Reorganizing ...Done');
utl_file.fclose(v_ID);
END;
Everything works fine, BUT, the script is generated in dos/windows scripting.
Now I need to run the script in *nix/linux shell, which I still can’t do it (because of my knowledge :p).
And also I don’t know if the script already generated in *nix/linux shell version, how do I chmod +x the script from stored procedure, I can’t use ‘host’ command in my tools
Thanks a lot
-firmanIf you're using 9i then UTL_FILE.FRENAME() will execute something like a Unix mv command.
If you want to do a chmod then you'll need to check out how to use a Java Stored Procedure to execute OS calls.
Cheers, APC -
Open a PDF file in linux using java
Hi..
How can I open a PDF file in linux using java.
I am able to open PDF in windows and mac using this code
in Windows
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
in mac
Runtime.getRuntime().exec("open " + path_of_PDF);
But nothing is working with linux.
Please help
ThanksOne thread is enough:
http://forum.java.sun.com/thread.jspa?threadID=5267458 -
Open PDF file in linux using java
Hi..
How can I open a PDF file in linux using java.
I am able to open PDF in windows and mac using this code
in Windows
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
in mac
Runtime.getRuntime().exec("open " + path_of_PDF);
But nothing is working with linux.
Please help
Thanksappi wrote:
Hi.. I found the JDIC binary files. There are different binaries for all the plateform. Is there any solution which is independent of plateform.Yes, and we already told you: Use JDK6, which has those libraries built into the standard class library.
How can I use these binaries in my existing project. does it work, If I place them at same place where other .class files are kept.Read the documentation of the JDIC project. I'm sure they answer this question in their FAQ. -
Convert XML file into DTD using Java
Hi All,
I want to do convert the xml file into DTD using Java.
I read the DOM package but didnt get clear idea.
Anyone of you have an idea please share the coding with me.
Any suggestions greatly appreciated.
Thanks
VeeraHi All,
I want to do convert the xml file into DTD using Java.
I read the DOM package but didnt get clear idea.
Anyone of you have an idea please share the coding with me.
Any suggestions greatly appreciated.
Thanks
Veera -
How to view file from vss using java Commandline
Hi To ALL,
I wanted to view a file from vss through java code.
By using the folowing code,i could able to get vss file in to local folder.
Runtime.getRuntime().exec
("cmd /c ss Get $/Mywork/Myfile.java -GLC:/New");
But i wanted to view file from vss using java code.
any one please help me..
Thanks in advance.........As always, Google is your friend.
Follow the bouncing link.
http://www.google.com/search?hl=en&q=VisualSourceSafe+%2B+Java+API
PS. -
Creating file browser GUI using java swing tree
Hi all,
I have some questions which i wish to clarify asap. I am working on a file browser project using java swing. I need to create 2 separate buttons. 1 of them will add a 'folder' while the other button will add a 'file' to the tree when the buttons are clicked once. The sample source code known as 'DynamicTreeDemo' which is found in the java website only has 1 add button which is not what i want. Please help if you know how the program should be written. Thx a lot.
Regards,Sorry, don't know 'DynamicTreeDemo'import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.io.File;
public class Test extends JFrame {
JTree jt = new JTree();
DefaultTreeModel dtm = (DefaultTreeModel)jt.getModel();
JButton newDir = new JButton("new Dir"), newFile = new JButton("new File");
public Test() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = getContentPane();
newDir.setEnabled(false);
newFile.setEnabled(false);
jt.setShowsRootHandles(true);
content.add(new JScrollPane(jt), BorderLayout.CENTER);
File c = new File("C:\\temp");
DefaultMutableTreeNode root = new DefaultMutableTreeNode(c);
dtm.setRoot(root);
addChildren(root);
jt.addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent tse) { select(tse) ; }
JPanel jp = new JPanel();
content.add(jp, BorderLayout.SOUTH);
jp.add(newDir);
jp.add(newFile);
newDir.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
TreePath tp = jt.getSelectionPath();
if (tp!=null) {
DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
File newFile = new File((File)dmtn.getUserObject(),"foo");
if (newFile.mkdir()) {
dmtn.add(new DefaultMutableTreeNode(newFile));
dtm.nodeStructureChanged(dmtn);
} else System.out.println("No Dir");
newFile.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
TreePath tp = jt.getSelectionPath();
if (tp!=null) {
DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
File newFile = new File((File)dmtn.getUserObject(),"foo.txt");
try {
if (newFile.createNewFile()) {
dmtn.add(new DefaultMutableTreeNode(newFile));
dtm.nodeStructureChanged(dmtn);
} else System.out.println("No File");
catch (java.io.IOException ioe) { ioe.printStackTrace(); }
setSize(300, 300);
setVisible(true);
void select(TreeSelectionEvent tse) {
TreePath tp = jt.getSelectionPath();
newDir.setEnabled(false);
newFile.setEnabled(false);
if (tp!=null) {
DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)tp.getLastPathComponent();
File f = (File)dmtn.getUserObject();
if (f.isDirectory()) {
newDir.setEnabled(true);
newFile.setEnabled(true);
void addChildren(DefaultMutableTreeNode parent) {
File parentFile = (File)parent.getUserObject();
File[] children = parentFile.listFiles();
for (int i=0; i<children.length; i++) {
DefaultMutableTreeNode child = new DefaultMutableTreeNode(children);
parent.add(child);
if (children[i].isDirectory()) addChildren(child);
public static void main(String[] args) { new Test(); } -
How to extract .sit files(in MAC) using java program
Hi,
please help me , i want to simple program for
" how to extract .sit files(in MAC) using java program"
that sit files same as zip files in windows..[Thanks for reply...
but i search in the google about this topic...there is no results will appear..
the problem is "i have to run program in the MacOS like extract all the
.sit(StuffIt) extension files. These sit files same as zip files in the windows... we have one tool called StuffIt Expander but it is 3rd party tool. but here requirement is i have to write my own program to extract all the files same as zip file program...
please do the needful..i am waiting for ur reply,,, -
Open a file dialog box using java
Duncan & Frank or anyone
Can you please tell, or give me a link, which explains how to open a file dialog box using java, and not webutil.
I'm trying to read a file on the desktop and update a database table.
ThanksSee Open File Dialog on the WEB... If you can get me the full version numbers I can tell you your supported position.
Regards
Grant -
Is It Possible to store an entire file in database using java?
Hi All,
I am new to Programming. please help he out Is It Possible to store an entire file in database using java? is possible, can u tell me the way to make this success? Thank you in advance.Thanks PhHein
i got that application. i stored one file in db, and i displayed that in browser. thank u very much. -
Unable to locate existing file from unix using java program
Hi
I have created a file in unix using java program, file.createNewFile();
And when i try to search for the same file using file.exists() it is returning false. Paths are correct. Can anybody help me out.
Thanks & Regards,
PrasanthIn Linux FC5 using JDK1.6, this code File temp = new File(System.getProperty("user.home") + "/abcdefghijklmn");
System.out.println(temp.createNewFile());prints 'true' and the file is created with length zero.
Maybe you are looking for
-
How do you recover a book from iPhoto after it crashed
After working on a book every night for 6 months iPhoto suddenly told me today that the theme was no longer available and to change to another and the pictures would transfer and I could continue. I duplicated the book then did as instructed. Both bo
-
New HDD not working. Please advise.
Hello. Today i purchased a new internal hdd for my 5.53 ghz macbook pro. I purchased the seagate momentus 500 gb 7200 rpm drive as suggested by users. The installation was fine, however i am having several issues with the drive. I boot into the 10.6
-
Unread Mail badges won't go away
Mail v7 (1822). Anyone else have this issue? I have many folders set up within Mail. I have an IMAP account, but have Rules to transfer messages to folder On My Mac. What's started to happen is the badges that usually appear associated with the folde
-
Mapping Error - Dump source message to file adapter comm channel
Hi Does anyone know of a way to dump the source message to a file adapter comm channel if - and only if - the message fails during mapping. For example, we receive a message from a trading partner that lacks an element that is mandatory during the ma
-
Why javax.faces.ViewState value of a form is too long ?
I'm trying to make a form with jsf, but when it is rendered javaxfaces.ViesState value of input hidden is too long!! Why ? My form: <h:form id="f" > <h:outputText value="#{commonMsg.titleHea1}: " /> <h:inputText size="6" id="search" value="#headerBea