This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes Loadjava program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Loadjava program" Watch "Loadjava program" New topic
Author

Loadjava program

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Hi

I have a Java class that will read the files and insert some data in the database. Currently by using loadjava command we loaded the class in the schema. Noe that class is running on the Oracle JVM(on the server). But my requirement is to pass the file from the Local machine(Ex: C:\test.txt). But the java class running on the server is searching the file in the server and throwing file not found exception.

Please assist me to resolve the issue.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Please Carefully Choose One Forum. Moving to our databases forum.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42355
    
  64
The answer seems obvious: either upload the file to the server, or run the Java class on the client where it has access to the file. Am I missing something?


Ping & DNS - my free Android networking tools app
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Apache commons is the best option to upload the file to the server ? or any thing else
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42355
    
  64
That depends on what kind of access you have to the server- HTTP, WebDAV, FTP, shared directory, something else?
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
simple FTP
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42355
    
  64
Then the Apache Commons Net library would indeed be a good choice.
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Apache Commons Net library is not suitable for my requirement. Could you please assist me with some other FTP. I just want to copy the file from the client machine to unix server.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42355
    
  64
Apache Commons Net library is not suitable for my requirement.

Why not? What is your requirement? If you want to upload a file programmatically to a machine to which you only have FTP access, then you will need to use an FTP library, no?
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Am unable to load the commons-net-1.4.1.jar in the schema. This jar depends on lot of jar.

am unable to find all the dependent jars.


Java class is running in the unix machine. I have

IP address
login user
login pwd of the unix machine.

How to transfer a file from a client(windows machine) to unix server where the java is running.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42355
    
  64
Am unable to load the commons-net-1.4.1.jar in the schema.

What does "in the schema" mean? You seem to use that term to indicate that the code is running as part of the server; is that correct? If so, that is the wrong place for this code: Commons Net would be used for implementing the FTP client that connects to the FTP server that you said was available on the server already.

This jar depends on lot of jar. am unable to find all the dependent jars.

Try harder. The error messages you'll get for missing classes provide excellent clues.
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Ulf,

My java code is not runing on the client Machine. It's running on the ORACLE JVM I load the java class in the schema using loadjava command.

So now the code is running in the Oracle JVM which inside (Unix machine). Now I need to transfer the file from the windows machine to Unix machine.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42355
    
  64
Let's take a step back. You have a file that you want to transfer to a server that is only FTP-accessible (at least that's what you said in your 3rd post). In your 5th post you're indicating that you have a username/password for login - do you mean Telnet by that, or SSH, or FTP?

Also, do you want to transfer the file manually or programmatically?
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
I want to transfer the file programmatically.

Basically Server denote my Unix box. We can't transfer a file with out authentication(userid, pwd) rite.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2504
    
    8

I have done this before using ANT scripts.

First the ANT FTP task to upload a file,
then the ANT TELNET task to call the command to process the file on the server.


OCUP UML fundamental and ITIL foundation
youtube channel
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
Meet Gaurav wrote:I want to transfer the file programmatically.

Basically Server denote my Unix box. We can't transfer a file with out authentication(userid, pwd) rite.


As far as I understood you must use your ftp stuff on your client side, so no need to embed ftp client library on oracle using loadjava.

On client machine -either linux or windows- the simpliest way that comes in my mind is to use a some peice of shell script to make ftp to database server. Then you can use utl_file to access it within your database.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loadjava program