> Hi Guys!
>
> How can i get java to recognize the Package
> oracle.jdbc.driver. i can't even compile my code, i
> get the error:
> package oracle.jdbc.driver does not exist
> import oracle.jdbc.driver.*;
You should not be importing oracle classes. You should only need them at runtime. JDBC is set of interfaces which abstract you from having to build only for a specific database.
The only exception is if you are doing something that absolutley requires the use of vendor specific stuff. Like Oracle Blobs I think.
But generally importing specfic driver packages is a no-no.
If you really need to (because of the exceptional condition) then you need to add the things (jars, zips or whatever) with the Oracle driver to your classpath the same way you have added them to your classpath when you run your program.
u have to import a package like
import java.sql.*;
for this you have to set classpath for classes111_01.jar. It contains the drivers.
Yeah! ive got the import java.sql.*; statement in my code. i've set the class path on the command prompt like this:
set classpath=.;c:\oracle\ora92\jdbc\lib\classes111.zip;c:\oracle\ora92\jdbc\lib\charset11.zip;c:\oracle\ora92\jdbc\lib\ojdbc14.jar
any suggestions?
Yes don't do that. See reply 2. Also because setting the classpath as environment variable is a bad idea anyway.
Do this instead
javac -classpath .;otherjaryouwanttohave.jar YourSourceFile.java
But really do read reply 2. It was full of good advice even if you didn't at first glance seem to think so.
Gosh! a new set of problems now.
I'm trying to run one of the jdbc programs from the java tut, CreateCoffees.java
I got the error:
ClassNotFoundException: oracle.jdbc.driver.OracleDriver
SQLException: No suitable driver.
the line in my code reads:
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
...
...
any suggestions? please.
It's wherever you put it. Or wherever your Oracle installer put it.
For example, on my machine the appropriate driver for my version of Oracle is in C:\oracle\ora92\jdbc\lib - see if you've got a similar directory. Note that it's the JAR file that has to be on the classpath, not just the directory containing it.
If you haven't put it on your machine, and you haven't installed the Oracle client software, then you might not have it at all.
If you don't understand the above, you need to learn more about the classpath before trying to get a database connection working. Walk first, run later.
Dave.
> > Hi Guys!
> >
> > How can i get java to recognize the Package
> > oracle.jdbc.driver. i can't even compile my code,
> i
> > get the error:
> > package oracle.jdbc.driver does not exist
> > import oracle.jdbc.driver.*;
>
> You should not be importing oracle classes. You
> should only need them at runtime.
Unless you need to use something specific to Oracle which the general interface does not cover. For instance some of the complex types that Oracle allows.
> > > Hi Guys!
> > >
> > > How can i get java to recognize the Package
> > > oracle.jdbc.driver. i can't even compile my
> code,
> > i
> > > get the error:
> > > package oracle.jdbc.driver does not exist
> > > import oracle.jdbc.driver.*;
> >
> > You should not be importing oracle classes. You
> > should only need them at runtime.
>
> Unless you need to use something specific to Oracle
> which the general interface does not cover. For
> instance some of the complex types that Oracle allows.
Please actually read an entire post. I did say in the very next paragraph "The only exception is if you are doing something that absolutley requires the use of vendor specific stuff. Like Oracle Blobs I think."
>
> Please actually read an entire post. I did say in the
> very next paragraph "The only exception is if you are
> doing something that absolutley requires the use of
> vendor specific stuff. Like Oracle Blobs I think."
Argghhh....yes I suppose it would help if I read the entire thing.
> Can you please suggest me what path must i include in
> my classpath so as to have the oracle driver jar
> available?
It has to be the same way as scsi-boy suggested for compilation.
java -classpath "all the classpath directories and jars here" ClassName