?
Solved

Error: package oracle.sql does not exist

Posted on 2005-03-29
14
Medium Priority
?
1,223 Views
Last Modified: 2012-05-05
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
Comment
Question by:Inayat081501
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
14 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13655275
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 13655288
And 'port' can just be declared as int
0
 

Author Comment

by:Inayat081501
ID: 13655391
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Accepted Solution

by:
CEHJ earned 300 total points
ID: 13655430
Should be

 ftpClient = new FtpClient(host, port);
0
 

Author Comment

by:Inayat081501
ID: 13655454
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 13655508
ok
0
 

Author Comment

by:Inayat081501
ID: 13655532
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 13655636
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 13655701
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
 

Author Comment

by:Inayat081501
ID: 13655853

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
 
LVL 86

Expert Comment

by:CEHJ
ID: 13656541
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
 

Author Comment

by:Inayat081501
ID: 13656637
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 13656703
That error comes about because of

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

and there *is* no last forward slash
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13661011
:-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question