cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing Oracle through web dynpro java

paskal_singh
Explorer
0 Kudos

Hi Experts,

I'm trying to access my ORADB through web dynpro java and I can't figure out why I keep getting an exception ClassNotFoundException: oracle.jdbc.driver.OracleDriver. Here are the steps I took:

I downloaded the Oracle JDBC driver from the oracle site. I downloaded the 11g drivers. (On the oracle site it says its for Java 1.5 sdk, I'm running NWDS 7.0.26 which uses Java 1.4.2, don't know if this might be causing the issue?)

I created a local webdynpro project, as I just wanted to test the functionality.

In my component controller I created a method called callOracleStoredProcedure and wrote the following code:

import java.sql.*;

import oracle.jdbc.driver.OracleDriver;

public void callOracleStoredProcedure()

{

   try

   {

      Class.forName("oracle.jdbc.driver.OracleDriver"); // This line fails

      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver); // This line fails also.

     // There is more code here but I cannot even get passed the above two lines

   }

   catch(Exception e)

   {

      wdComponentAPI.getMessageManager().reportException(""+e, true);

   }

}

I alternate the usage of the above two lines, not using at the same time.

In my project I have added an external jar file to the java build path and the entry shows up in the classpath also. However, the weird thing is if I click on Project->repair, it removes the jar file entry! Why?

Can someone please shed some light for me? I know there are other threads which explore the possiblity of adding a datasource through Visual Admin configuration, but I want to try it this way first without going thru writing any actual SQL statements. The stored procedure im trying to call returns a ref cursor and I want to just make the call, retrieve the data and copy into my WDPJ context. But why can't I load the driver and why doesn't Web Dynpro find the class even though the jar and everything is there?? Totallly baffled!

Please HELP!

Paskal.

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
0 Kudos
you have two problem
1. the driver depends on jdk 1.5, which won't work in jdk1.4 environment
2. you don't know how to use external lib
i would suggest to go with data source option.
a lot of people are suffering from the use of external lib. if you still want to go this way. you can search in sdn, there is a lot tutorial regarding how to use external lib.
paskal_singh
Explorer
0 Kudos

Hi Jun,

I've also tried the 1.4 driver, but it doesnt load anyway and errors out at the same line of code and that driver is for oracle 10g, I'm on 11g and so using the newer driver. Actually I do know how to use an external lib but I don't need to create an external lib...this is a local web dynpro project not a development component. it should load the driver locally as long as the jar file is included in the project.

junwu
Active Contributor
0 Kudos
where you put the jar?  there is lib folder for web dynpro project. you should put it there and try.
just put the jar at the build path is not enough.
paskal_singh
Explorer
0 Kudos

Thanks Jun, that did the trick.

Answers (0)