Skip to Content
avatar image
Former Member

WebDynpro java and Oracle Connection

Hi,

I'm trying to make a simple connection to an Oracle database within a custom webdynpro component. Using NWDS 7.0.08 and EP 7.0 SP 10.

Here is a sample of the java code I use :

Connection conn = null;

Class.forName("oracle.jdbc.driver.OracleDriver");

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

conn =DriverManager.getConnection ("jdbc:oracle:thin:@hostname:port:DATABASENAME","schema", "password");

Statement stmt=conn.createStatement();

ResultSet rs=stmt.executeQuery("select * from MYTABLE");

But when I run this WebDynpro, the following error appears :

"oracle.jdbc.driver.OracleDriver".

I have also catched the exception stack but it doesn't seem meaningful. If you need it, I can provide it in another thread.

So What should I do to connect to this oracle database ? Is it the right provider ?

Thanks,

Loïc LEVEUGLE

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 21, 2007 at 02:42 AM

    this is because jar file is not included in the path

    if it is oracle 10 version classes12.jar should be included in the classpath

    process to do that is

    1)right click on the project->properties->java build path->external build path->go to the location where jar file is file->add it

    2)copy the classes12.jar

    3)open the navigator perspective->right click on the lib folder of your webdynpro project->paste the jar file(classes12.jar)

    this should resolve the problem.If yes reward the points accordingly.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 20, 2007 at 02:09 PM

    Hi,

    See note 941594 for using Oracle Driver in the J2EE.

    Assuming you are using JDK 1.4 then you should use ojdbc14.jar

    The driver name should be: oracle.jdbc.OracleDriver

    If it doesn't work try to use: oracle.jdbc.pool.OracleDataSourceFactory

    Regards,

    Omri

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 20, 2007 at 03:59 PM

    Hi!,

    please try following code, this is working fine for me.

    String  serverName = "172.21.1.62";
    String portNumber = "1526";
    String sid = "vision";
    String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
    String userName = "scott";
    String password = "tiger";
    Connection connection = null;
    			
    try {
        // Load the JDBC driver 
        String driverName = "oracle.jdbc.driver.OracleDriver";
        Class.forName(driverName);
        connection = DriverManager.getConnection(url, userName, password);
        Statement stmt =connection.createStatement();
        PreparedStatement pstmt = connection.prepareStatement("insert into club (Name,EmpID,Location,Extention,MailID,InstPlay) values(?,?,?,?,?,?)");
    			pstmt.clearParameters();
    
        pstmt.setString(1,Name);
        pstmt.setString(2,EmpID);
        pstmt.setString(3,Location);
        pstmt.setString(4,Extention);
        pstmt.setString(5,MailID);
        pstmt.setString(6,Instrument);
        pstmt.executeUpdate();
    	
     } catch(Exception exc) {
    	exc.printStackTrace();
     } 
    

    put classes12.jar in your class Path.

    regards,

    Mithileshwar Sahu

    Add comment
    10|10000 characters needed characters exceeded