Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1266
  • Last Modified:

Error: package oracle.sql does not exist

Hello:

I am trying to compile the following java code and the get this error:
============================================
C:\>javac ftp_utility.java
ftp_utility.java:5: package oracle.sql does not exist
import oracle.sql.*;
^
ftp_utility.java:14: cannot resolve symbol
symbol  : class NUMBER
location: class ftp_utility
    NUMBER port,
    ^
2 errors
======================================
Here is my code:
======================================

import java.io.*;
import sun.net.ftp.*;
import oracle.sql.*;

import java.util.*;
import java.net.*;

public class ftp_utility {

public static void put(
    String host,
    NUMBER port,
    String username,
    String password,
    String sourceFile,
    String remoteDirectory ) throws Exception
    {

   // Modify system properties - 03/16/2005
     Properties sysProperties = System.getProperties();
     // Specify proxy settings
     sysProperties.put("proxyHost", "app-proxy"); //change IP address of proxy, apr-30-2004
     sysProperties.put("proxySet",  "true");
     sysProperties.put("proxyPort", "8080");
     System.setProperties(sysProperties);

     //sysProperties.put("socksProxySet", "true");
     ////sysprops.put("socksProxyHost", "socks.whitehouse.gov");
     //sysProperties.put("socksProxyHost", "ftpun01");
   //sysProperties.put("socksProxyPort", "8080");

        FtpClient ftpClient = null;

        try
        {
          int lastSlash = sourceFile.lastIndexOf('/');
          String file = sourceFile.substring(lastSlash + 1);
          String directory = sourceFile.substring(0, lastSlash);
          ftpClient = new FtpClient(host, port.intValue());
          ftpClient.login(username, password);
          ftpClient.cd(remoteDirectory);
          ftpClient.put(sourceFile);
         }
         finally
         {
          if (ftpClient != null)
          {
            ftpClient.closeServer();
          }
        }
    }
}

======================================

Could someone point out what am I missing here?  Thanks - Inayat
0
Inayat081501
Asked:
Inayat081501
  • 9
  • 5
1 Solution
 
CEHJCommented:
You're not using the oracle package so you may as well remove the declaration. If you need it later, you'll have to put it in your classpath
0
 
CEHJCommented:
And 'port' can just be declared as int
0
 
Inayat081501Author Commented:
Hi CEHJ,

Thanks for your quick response. I commented out the line

import oracle.sql.*, and I changed NUMBER to int for port, and now I get the following error.
Please let me know. Thanks.
=====================================
C:\>javac ftp_utility.java
ftp_utility.java:44: int cannot be dereferenced
          ftpClient = new FtpClient(host, port.intValue());
                                              ^
1 error
=====================================
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CEHJCommented:
Should be

 ftpClient = new FtpClient(host, port);
0
 
Inayat081501Author Commented:
hi CEHJ:

I got it. I changed

          ftpClient = new FtpClient(host, port.intValue());

to:
          ftpClient = new FtpClient(host, port);

and I was able to compile. However, I might come back to the forum for a little more clarification. Thanks. Inayat.
0
 
CEHJCommented:
ok
0
 
Inayat081501Author Commented:
CEHJ:

I am just learning some java. quite interesting.

I am now trying to call the "put" method in the above code, by passing hardcoded values for the various parameters. I need to have a main method. Correct? Say, if I want to have another method that calls the "put" method passing in
the values for the parameters as below, how do I do this?

ftpun01                            (string)
21                                   (numeric)
testuser                           (string)              
testpwd                           (string)
f:\clfy\infile\export123       (string)
\ftptest1                           (string)

Thanks - Inayat
0
 
CEHJCommented:
You could pass the values for put in the main method. I would put as few params as possible though or you're going to have parameter overkill. What's essential?
0
 
CEHJCommented:
To pass them all though, you can do:

public static void main(String[] args) {
      if (args.length < 6) {
            printUsageMessage(); // print a message showing correct parameter usage
      }
      else {
            put(args[0], Integer.parseInt(args[1]), args[2], args[3], args[4], args[5]);
      }
}
0
 
Inayat081501Author Commented:

In the code you have shown, within the main method, I want to hardcode the values of each of the 6 parameters to the specific values I have indicated above.  I don't want to pass arguments to the main method itself.

Thanks. Inayat
0
 
CEHJCommented:
In that case i'm getting confused. This is what i thought you were asking:

>>
Say, if I want to have another method that calls the "put" method passing in
the values for the parameters as below, how do I do this?
>>
0
 
Inayat081501Author Commented:
I am sorry I confused you.

Here is what I want to do. The put method takes in 6 parameters.

I want to be able to call this put method passing parameter values to it. How could I do this?

I thought I could do something like as I am showing below:

===========================================================
public static void main (String args[]) throws Exception {

String host = "ftpun01";
int port = 21;
String username = "bbb\\ijilani";
String password = "union28";
String sourceFile = "f:\\clfy\\infile\\export123";
String remoteDirectory = "\\ftptest1";

   put(host.toString(), port, username.toString(), password.toString(), sourceFile.toString(), remoteDirectory.toString());

}
===========================================================

I am getting errors when I run it, but it does compile.

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1444)
        at ftp_utility.put(ftp_utility.java:58)
        at ftp_utility.main(ftp_utility.java:24)

Could you please spot for me programmatic errors in the above code? --> Thanks - Inayat
0
 
CEHJCommented:
That error comes about because of

>>int lastSlash = sourceFile.lastIndexOf('/');

and there *is* no last forward slash
0
 
CEHJCommented:
:-)
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 9
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now