Solved

Java compile error creating new JDBC OracleDriver

Posted on 2001-07-26
10
331 Views
Last Modified: 2013-11-23
I need to query an Oracle database table via a java bean.  In the middle of the page 4 of ?Readme? for JDBC it says "Your JDBC program must register the Oracle driver. . . make sure that the following statement is executed. . .DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver ());"

I put that line in the bean script and when I tried to compile it I got:

nameBean.java:25: cannot resolve symbol
symbol  : class OracleDriver
Location: package driver
DriverManager.registerDriver (new oracle.jdbc.driver .[a carrot points to this dot]OracleDriver())

My classpath leads to ?classes12.zip?, and within that package are two files called ?OracleDriver.class?.  I also tried setting classpath to ?classes111.zip? that has only one ?OracleDriver.class?.

I tried compiling a demo script that came with the JDBC (ResultSet1.java) and got the same error.

(I am new to this forum, as well as to Java so please forgive me if this is something simple I should be able to figure out for myself.)

                                     
0
Comment
Question by:DwayneMartin
10 Comments
 
LVL 3

Expert Comment

by:black
ID: 6325018
Looks like a classpath issue. Are you running this code from an Application server or from command line?

You can also try:
Class.forName("oracle.jdbc.driver.OracleDriver");
this basically registers too, but you are going to get a runtime ClassNotFoundException if the classes12.zip is not in the classpath.
0
 
LVL 1

Expert Comment

by:poluru
ID: 6325506
try compiling  by giving the classpath at the prompt itself
like

java -classpath c:\oracle\ora81\lib\classes12.zip MyBean.java

(i assumed that the classe12.zip is there in c:\oracle\ora81\lib folder)
0
 

Author Comment

by:DwayneMartin
ID: 6327272
I am trying to compile the code from the command line on a Win2000 server, IIS  web server. Classpaths are defined in "http://localhost/servlet/admin?setVMSettings".  I've tried the following:

1. Leaving the class object in the zip folder.
My classpath says "C:\Oracle\Ora81\jdbc\lib\classes111.zip".  If I copy that line and paste it into Windows Explorer it opens classes111.zip and OracleDriver.class is there, so I am pretty sure there aren't any typo's.

2. Putting the class object in a folder.
I also have  "C:\Oracle\Ora81\jdbc\lib" in my classpath, so I extracted OracleDriver.class into  "C:\Oracle\Ora81\jdbc\lib".

3. Putting the class object in a package.
Since the error message says "location: package driver" I created a "driver" folder within  "C:\Oracle\Ora81\jdbc\lib" and moved OracleDriver.class there.

But I always get the same compile error.
0
 
LVL 5

Expert Comment

by:nebeker
ID: 6327701
How are you setting the classpath?
0
 
LVL 7

Expert Comment

by:Igor Bazarny
ID: 6327906
Hi,

> Classpaths are defined in "http://localhost/servlet/admin?setVMSettings"
I believe it's IIS-specific settings which don't affect classpath used by compiler. Try to set CLASSPATH environment variable or pass -classpath parameter in javac commandline. BTW, do you try to compile using commandline tools or you are using some IDE? For IDE you need to configure classpath within IDE settings.

Regards,
Igor Bazarny
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:DwayneMartin
ID: 6329931
Thank you all for helping a beginner learn the system.

I've taken all three of your advices, but keep getting the same error.

1. I tried to compile by typing "javac -classpath c:\oracle\ora81\lib\classes111.zip nameBean.java."  (I presume you meant "javac" not "java".)

2. I added the line "Class.forName("oracle.jdbc.driver.OracleDriver");" just above "DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());"  (Is this what you meant?)

3. I defined a system variable "classpath" as  C:\Oracle\Ora81\lib\classes111.zip. (I especially appreciated this info because after I submitted my question it occurred to me that the pc system may not be able to use the web server classpath.)

Please let me know if I've misunderstood any of your suggestions, and I very much appreciate your helpfulness.  (I'll be gone till Friday, Aug 2, so if I don't reply right away to any future comments please don't think I've lost interest.)
0
 
LVL 3

Accepted Solution

by:
shyamkumarreddy earned 50 total points
ID: 6337200
Hey Martin

For Compiling in Command Prompt.
Please add your classpath of oracle classes in your system. using mycomputer environment variables.
And the classpath and reboot the sytem
You can now compile the File.
Or

javac Resultset.java -cp c:\pathoforacleclass\classes12.zip
Okay


I need the following answers from you.
What Web Server are you using?
0
 

Author Comment

by:DwayneMartin
ID: 6348839
It compiled!  Thank you all for your help.  To summarize what I've learned:

1. The command line compiler can't use the web server classpath.  You have to define a web server classpath AND an environment variable.

2. You have to reboot for the environment variable to take effect. (I knew that I just forgot.  Sorry!)
0
 

Expert Comment

by:CleanupPing
ID: 9061945
DwayneMartin:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9208323
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


[points to shyamkumarreddy]


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
advertisement module in core php 4 145
maven example error 3 52
Groovy:unable to resolve class error 2 69
thymeleaf natural templating vs JSP 2 67
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now