2
votes

I am experiencing the strange problem with No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE

when i run JUNIT Test case of any DAO it is inserting fine. But when i run in server it is giving No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE

i have added ojdbc14.jar to WEB-INF/lib folder.

here is the jdbc.properties

jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:XE
jdbc.username=system
jdbc.password=pwd

please help me.

6
Make sure the Oracle JDBC jar is on your classpath.FThompson

6 Answers

7
votes

The problem is its not loading the Oracle Driver

added this in Controller, every thing is working fine.

static{
    try {
        Class.forName ("oracle.jdbc.OracleDriver");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}
2
votes

If your database connection module is in the server, you must add the driver jar to the container, and not deploy it with your WAR. It is a Classpath problem.

2
votes

you have to import ojdbc6.jar to the libraries like i did

  1. in the left side of netbeans theres a project bar
  2. right click on the libraries and select "add JAR/FOLDER"
  3. then select the ojdbc.jar
  4. then voilaa :D
0
votes

For beginners. Download the ojdbc14.jar file

then right click on the folder you are working on and go to its properties

enter image description here

Click library, Then find the downloaded ojdbc14.jar file to add it to the library

enter image description here

From there you are good to go

0
votes

used this as the solution, worked like a charm!! thanks Ramesh Kotha

 static{
        try {
            Class.forName ("oracle.jdbc.OracleDriver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } }
-2
votes

In WEB-INF/lib ojdbc14-10.2.0.2.0, ojdbc8 or ojdbc6 should be there. I have faced the same issue and resolved by this way.

See the attached.

attached image