JDBC Excpetion

Hello experts,

I have many web application deployed on my tomcat. when i restart tomcat and run one of the applicationm it gives:
No suitable driver found for jdbc:oracle:thin:@tibisdb.uaeu.ac.ae:1526:tlum
when i run another application, expcetion gone and all things working fine :s

do u have any idea why this happen to me :s
Web_AdminAsked:
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.

Mick BarryJava DeveloperCommented:
do you have the required driver jar installed in tomcats lib directory
0
Web_AdminAuthor Commented:
I put classes12.jar in the lib folder  of the tomcat
0
Mick BarryJava DeveloperCommented:
what version of tomcat?
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.

Web_AdminAuthor Commented:
version 6
0
CEHJCommented:
>>when i run another application, expcetion gone and all things working fine :s

That's probably because the working application includes the driver jar in WEB-INF/lib
0
Mick BarryJava DeveloperCommented:
where do you actually define the database connection configuration?
0
Web_AdminAuthor Commented:
CEHJ:

i don't have any lib folder in the web-inf for the applications. i just have classes folder under web-inf for each application
0
Mick BarryJava DeveloperCommented:
> i don't have any lib folder in the web-inf for the applications. i just have classes folder under web-inf for each application

irrelevant anyway, wouldn't make any difference
0
Web_AdminAuthor Commented:
objects:

I put driver jar in the tomcat lib under "Conf" folder. and for each application i have class folder under web-inf, shall i have lib folder for each application and copy the jars?
0
Mick BarryJava DeveloperCommented:
the driver should just be in /lib
(not conf, nor in your application)
0
enggagrawalCommented:
try ur driver in web-inf/lib dir
0
Web_AdminAuthor Commented:
Hello Experts,

it is still the case,

is this piece of code would help?

"Class.forName("myJDBCDriver").newInstance();"
0
CEHJCommented:
>>is this piece of code would help?

No. Only putting the jar in the correct place will help. If you don't have access to $CATALINA_HOME/lib, then place the jar as mentioned at http#30016119
0
CEHJCommented:
0
enggagrawalCommented:
import java.io.*;
import java.sql.*;

public class OraThin {
  public static void main(String[] args) {
    try {
      Connection con=null;
      Class.forName("oracle.jdbc.driver.OracleDriver");
      con=DriverManager.getConnection(
        "jdbc:oracle:thin:@machine_name:1521:database_name",
        "scott",
        "tiger");
      Statement s=con.createStatement();
....
}}}
machine name for local computer: localhost
0
enggagrawalCommented:
Also check your classpath in windows properties
0
Web_AdminAuthor Commented:
CEHJ:

I have checked for million times now that classes21.jar is in the tomcat lib directory.
I tried to remove it from tomcat lib and put in the application WEB-INF/lib and didn't work.

enggagrawal:

do u mean i should add the path of classes21.jar to the "PATH" environment variables?
0
enggagrawalCommented:
yes add to CLASSPATH environment variable

and its classes12.jar
0
Web_AdminAuthor Commented:
the classes of the application that connects to the database r zipped in jar file and placed in $CATALINA_HOME/lib. but the classpath in the MANIFEST is not defined.

is this may cause the problem ?
0
enggagrawalCommented:
put classes12.jar in project_root/web-inf/lib directory
Classpath for env variable

.;..;drive:\\apache-tomcat-5.5.20\webapps\project\WEB-INF\lib\classes12.jar;
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
CEHJCommented:
>>the classes of the application that connects to the database r zipped in jar file and placed in $CATALINA_HOME/lib.

No - that's incorrect. Only jars common to all projects should be there, so - your driver jar

The project classes should be in WEB-INF/classes and jars in WEB-INF/lib
0
Web_AdminAuthor Commented:
Ok guys,

I put the classes and jar in each application folder now under WEB-INF.
all apps r working fine, so for now i will monitor the Exception if it happens again

Thanks enggagrawal and CEHJ for ur time :)
0
CEHJCommented:
:-)
0
Mick BarryJava DeveloperCommented:
be careful doing that it can cause issues (and is unnecessary)
you're probably just masking the real error
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
JSP

From novice to tech pro — start learning today.