sun.jdbc.odbc.jdbcodbcdriver: How to do CLASSPATH

I want to use sun.jdbc.odbc.jdbcodbcdriver and I'm having trouble setting the CLASSPATH.  I have searched high and low for instructions on how to set CLASSPATH, and can't find any.  Would somebody please tell me how to set CLASSPATHs for drivers?  I mean the basics... like where do you go to do it, what commands to run, how do you check to see if you've done it correctly, etc... please help.  Much appreciated.

Also, is there a problem with using this in an applet?  Do I need to use JSP instead?  Thanks from inexperienced Java person here... also a basic beginners book recommendation that is detailed enough to get me into jsp/servlet applications would be highly appreciated as well.
cxxxcxxxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jimmackCommented:
You may be having trouble simply because it's:

sun.jdbc.odbc.JdbcOdbcDriver

(case sensitive).
0
jimmackCommented:
I would highly recommend

Core Servlets and Java Server Pages (2nd edition) by Marty Hall and Larry Brown.

http://www.coreservlets.com and http://www.moreservlets.com
0
jimmackCommented:
From your question about applets or JSP (and your interest in JSP/Servlets), I would guess that you should go straight for the JSP route ;-)
0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Mick BarryJava DeveloperCommented:
you don't need to do anything to your classpath to include that driver it is already available.

> Also, is there a problem with using this in an applet?

yes, the default permissions for an applet will not allow its use.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mick BarryJava DeveloperCommented:
good general tutorial on java available at:
http://java.sun.com/docs/books/tutorial/
0
jimmackCommented:
Some information I missed in my previous posts.

You don't need the classpath for this driver since it's available in the JRE (it's in rt.jar).

For other drivers, you just need to include the .jar file that contains them in your classpath.  Usually, you put these jar files in the /lib/ext directories.  JAR files in this directory don't need to be added to the classpath.

If the driver isn't availble to the runtime environment (assuming you're using Class.forName(...)), then this line would throw a ClassNotFoundException.
0
jimmackCommented:
Hi objects ;-)
0
Mick BarryJava DeveloperCommented:
:-)
0
cxxxcxxxAuthor Commented:
OK... here's the deal guys.  All I need to do is have a web page collect userid and password, then write userid and password to a database.  Then I need to have another web page for them to log in.... check the same database for valid userid and password, then let them in to yet another web page.  I'm getting the following errors:  unable to resolve symbol connection, and  unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown.

I know this is simple for you guys, but it's important that I have answers to this before I even read the java for dummies book.  I think you're suggesting I use jsp page with a servlet?  If so, what's the best way to go about it?  I'm using netbeans ide 3.5.1.  The thing that makes me frustrated is that when I add a jsp page, I don't get a nice GUI to work with.... if I add a jframe form from the java GUI form section, then I do get the GUI to work with.  So I guess what I really need is a jump start... put me in the right direction and I'll be good to go.  Simple questions, but very important.
0
cxxxcxxxAuthor Commented:
OK... here's the deal guys.  All I need to do is have a web page collect userid and password, then write userid and password to a database.  Then I need to have another web page for them to log in.... check the same database for valid userid and password, then let them in to yet another web page.  I'm getting the following errors:  unable to resolve symbol connection, and  unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown.

I know this is simple for you guys, but it's important that I have answers to this before I even read the java for dummies book.  I think you're suggesting I use jsp page with a servlet?  If so, what's the best way to go about it?  I'm using netbeans ide 3.5.1.  The thing that makes me frustrated is that when I add a jsp page, I don't get a nice GUI to work with.... if I add a jframe form from the java GUI form section, then I do get the GUI to work with.  So I guess what I really need is a jump start... put me in the right direction and I'll be good to go.  Simple questions, but very important.
0
Mick BarryJava DeveloperCommented:
if you want to use an applet, then you'll need to either get a different driver, or have your applet call a servlet on the server which will perform the db access.
0
Mick BarryJava DeveloperCommented:
to get a connection:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
Connection con = DriverManager.getConnection(connectstring);

the 1st line is only needed to be called once.
0
jimmackCommented:
The "must be caught or declared to be thrown" means that you need to put the Class.forName() inside a try ... catch, eg.

try
{
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   .
   .
   .
}
catch (ClassNotFoundException cnfe)
{
   System.err.println(cnfe.toString());
}

Make sure that you do the rest of the database bits (eg. getting a connection etc.) inside the try as well (there's no point doing these things if the driver can't be found).

A JSP page is (basically) just an HTML page with some Java code added between <% and %>.

0
Mick BarryJava DeveloperCommented:
0
jimmackCommented:
Did anybody else get shut-out of EE for the last 1/2 hour (with cyclic links in the questions) or was it just me?
0
Mick BarryJava DeveloperCommented:
> or was it just me?

no it appears they were tinkering again.
0
jimmackCommented:
Do you have a servlet container yet (eg. Tomcat)?

If not, you can download it from http://jakarta.apache.org/tomcat/index.html
0
jimmackCommented:
One last thing before I go to bed.  If you go to the coreservlets.com site and scroll down to the bottom of the page, the first edition of Core Servlets and Java Server Pages is available as a free pdf (yes, the whole book ;-)).

If you have a look through that, you'll get a good introduction.

When the EE developers finish tootling with the site ;-), you could try a search for "JdbcOdbcDriver" in the JSP Topic Area.  You might find some JSP code that will give you a good start.
0
paragagarwalCommented:
When you are using the driver :- sun.jdbc.odbc.JdbcOdbcDriver() , it means that you are using Type1 Driver ie making ur java driver is making call to the ODBC provider. There is no need to set the classpath for it. You just have to load the class for this driver thru Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").

Ofcourse ur JDK should be in the path to run ur java application.

Applet Problem:-
You cant use the Type 1 Driver in Applet as applet cant access the File System on the client.
0
Mick BarryJava DeveloperCommented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.