cancel
Showing results for 
Search instead for 
Did you mean: 

Connection to an Oracle DB

Former Member
0 Kudos

Hi,

I have a small app running in WD which returns the data of a table in a SAP system (via Adaptive RFC model).

It all goes wrong when I want to enrich my WD app with data of the Oracle DB.

My code is as follows:

<b>Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con = DriverManager.getConnection("jdbc:oracle:thin:@<server ip>:<port>:<sid>", User, Password);</b>

The exception occurs when the code reaches the "Class.forName..." line and gives the error:

<b>java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

-


Loader Info -


ClassLoader name: [sap.com/xi_monit]

Parent loader name: [Frame ClassLoader]

References:

common:service:http;service:servlet_jsp

service:ejb

common:service:iiop;service:naming;service:p4;service:ts

service:jmsconnector

library:jsse

library:servlet

common:library:IAIKSecurity;library:activation;library:mail;library:tcsecssl

library:ejb20

library:j2eeca

library:jms

library:opensql

common:library:com.sap.security.api.sda;library:com.sap.security.core.sda;library:security.class;library:webservices_lib;service:adminadapter;service:basicadmin;service:com.sap.security.core.ume.service;service:configuration;service:connector;service:dbpool;service:deploy;service:jmx;service:jmx_notification;service:keystore;service:security;service:userstore

interface:resourcecontext_api

interface:webservices

interface:ejbserialization

sap.com/tcwddispwda

sap.com/tcwdcorecomp

service:webdynpro

service:sld

library:tcddicddicservices

library:com.sap.aii.proxy.framework

library:tcgraphicsigs

library:com.sap.mw.jco

library:com.sap.lcr.api.cimclient

library:sapxmltoolkit

library:com.sap.aii.util.rb

library:com.sap.util.monitor.jarm

library:tcddicddicruntime

library:com.sap.aii.util.xml

library:tccolapi

library:com.sap.aii.util.misc

library:tc~cmi

library:tccolruntime

Resources:

D:\usr\sap\XID\DVEBMGS00\j2ee\cluster\server0\apps\sap.com\xi_monit\webdynpro\public\lib\app.jar

Loading model: {parent,references,local}

-


</b>

The strange thing is, that when I make a small Java project, and include this code, it all works fine. It seems that I have to import the Oracle drivers somewhere else, but I do not know where.

Maybe someone already encountered this issue.

Bart

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

The Oracle driver jar (classes12.jar) is not available in the classpath.

1.you can create a driver in Visual Administrator under Services-> JDBC Connector

2. you can add the jar to the webdynpro project.

Creating a JDBC Driver and DataSource in the Visual Administrator will provide you a UI so that you can change the properties in future. i would recommend option 1.

Hope that helps.

Regards,

Divakar

Former Member
0 Kudos

Thx for the quick reply, but I'm still stuck somewhere.

1) I tried this one. I created a Driver and DataSource, but when I execute my code:

<b>InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/ORACLEDB");

Connection con = ds.getConnection();</b>

I get the following error:

<b>com.sap.engine.services.dbpool.exceptions.BaseSQLException: ResourceException in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: com.sap.sql.log.OpenSQLException: Error while accessing porting layer for ORACLE database via getDatabaseHost().</b>

Even when I want to test my Driver in the Visual Administrator (I set the initial connections to 1), I get the following error:

<b>java.rmi.RemoteException: Error occurred while making runtime changes with application sap.com/JDBCConnector_ORACLEDB.xml; nested exception is:

com.sap.engine.services.deploy.exceptions.ServerDeploymentException: Clusterwide exception: server ID 1732350:com.sap.engine.services.dbpool.exceptions.BaseDeploymentException: Cannot start DataSource "ORACLEDB". at com.sap.engine.services.dbpool.deploy.ContainerImpl.startDataSource(ContainerImpl.java:1549) at com.sap.engine.services.dbpool.deploy.ContainerImpl.startDataSources(ContainerImpl.java:1825) at com.sap.engine.services.dbpool.deploy.ContainerImpl.prepareStart(ContainerImpl.java:489) at com.sap.engine.services.deploy.server.application.StartTransaction.prepareCommon(StartTransaction.java:370) at com.sap.engine.services.deploy.server.application.StartTransaction.prepare(StartTransaction.java:318) at com.sap.engine.services.deploy.server.application.ApplicationTransaction.makeAllPhasesOnOneServer(ApplicationTransaction.java:299) at com.sap.engine.services.deploy.server.application.ParallelAdapter.makeAllPhasesImpl(ParallelAdapter.java:301) at com.sap.engine.services.deploy.server.application.ParallelAdapter.runInTheSameThread(ParallelAdapter.java:110) at com.sap.engine.services.deploy.server.application.ParallelAdapter.makeAllPhasesAndWait(ParallelAdapter.java:212) at com.sap.engine.services.deploy.server.application.RuntimeTransaction.finalActions(RuntimeTransaction.java:286) at com.sap.engine.services.deploy.server.application.ApplicationTransaction.makeAllPhases(ApplicationTransaction.java:332) at com.sap.engine.services.deploy.server.DeployCommunicatorImpl.makeRuntimeChanges(DeployCommunicatorImpl.java:337) at com.sap.engine.services.dbpool.deploy.DataSourceManagerImpl.updateDataSourceApplication(DataSourceManagerImpl.java:629) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.sap.pj.jmx.introspect.DefaultMBeanInvoker.invoke(DefaultMBeanInvoker.java:58) at com.sap.pj.jmx.mbeaninfo.AdditionalInfoProviderMBean.invoke(AdditionalInfoProviderMBean.java:289) at com.sap.pj.jmx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:944) at com.sap.pj.jmx.server.interceptor.MBeanServerWrapperInterceptor.invoke(MBeanServerWrapperInterceptor.java:288) at com.sap.engine.services.jmx.CompletionInterceptor.invoke(CompletionInterceptor.java:400) at com.sap.pj.jmx.server.interceptor.BasicMBeanServerInterceptor.invoke(BasicMBeanServerInterceptor.java:277) at com.sap.jmx.provider.ProviderInterceptor.invoke(ProviderInterceptor.java:255) at com.sap.engine.services.jmx.RedirectInterceptor.invoke(RedirectInterceptor.java:340) at com.sap.pj.jmx.server.interceptor.MBeanServerInterceptorChain.invoke(MBeanServerInterceptorChain.java:330) at com.sap.engine.services.jmx.MBeanServerSecurityWrapper.invoke(MBeanServerSecurityWrapper.java:287) at com.sap.engine.services.jmx.MBeanServerInvoker.invokeMbs(MBeanServerInvoker.java:157) at com.sap.engine.services.jmx.ClusterInterceptor.invokeMbs(ClusterInterceptor.java:220) at com.sap.engine.services.jmx.ClusterInterceptor.invoke(ClusterInterceptor.java:803) at com.sap.engine.services.jmx.MBeanServerInterceptorInvoker.invokeMbs(MBeanServerInterceptorInvoker.java:102) at com.sap.engine.services.jmx.connector.p4.P4ConnectorServerImpl.invokeMbs(P4ConnectorServerImpl.java:61) at com.sap.engine.services.jmx.connector.p4.P4ConnectorServerImplp4_Skel.dispatch(P4ConnectorServerImplp4_Skel.java:64) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:294) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:183) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:119) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37) at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)Caused by: com.sap.engine.services.dbpool.exceptions.BaseResourceException: SQLException thrown by the physical connection: com.sap.sql.log.OpenSQLException: Error while accessing porting layer for ORACLE database via getDatabaseHost(). at com.sap.engine.services.dbpool.spi.ManagedConnectionFactoryImpl.createManagedConnection(ManagedConnectionFactoryImpl.java:188) at com.sap.engine.services.connector.jca.ConnectionHashSet.init(ConnectionHashSet.java:151) at com.sap.engine.services.connector.jca.ConnectionHashSet.<init>(ConnectionHashSet.java:120) at com.sap.engine.services.connector.jca.AdapterCache.open(AdapterCache.java:207) at com.sap.engine.services.connector.ResourceObjectFactory.startConnectionFactory(ResourceObjectFactory.java:290) at com.sap.engine.services.dbpool.deploy.ContainerImpl.startDataSource(ContainerImpl.java:1540) ... 41 moreCaused by: com.sap.sql.log.OpenSQLException: Error while accessing porting layer for ORACLE database via getDatabaseHost(). at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:106) at com.sap.sql.jdbc.direct.DirectConnectionFactory.createContextFactory(DirectConnectionFactory.java:473) at com.sap.sql.jdbc.direct.DirectConnectionFactory.createDirectPooledConnection(DirectConnectionFactory.java:192) at com.sap.sql.jdbc.common.CommonConnectionFactory.createCommonPooledConnection(CommonConnectionFactory.java:126) at com.sap.sql.connect.OpenSQLConnectionFactory.createCommonPooledConnection(OpenSQLConnectionFactory.java:120) at com.sap.engine.services.dbpool.spi.ManagedConnectionFactoryImpl.createManagedConnection(ManagedConnectionFactoryImpl.java:174) ... 46 moreCaused by: java.sql.SQLException: Access to Oracle dictionary view V$INSTANCE failed. at com.sap.sql.jdbc.oracle.OraclePortingServices.getDatabaseHost(OraclePortingServices.java:207) at com.sap.sql.jdbc.direct.DirectConnectionFactory.createContextFactory(DirectConnectionFactory.java:463) ... 50 more</b>

2) This was for me the obvious solution, since I use it all the time with Java Projects --> No problem there !!!(in the NetWeaver Developer Studio), but this seems not to work in a WebDynpro Project/Development Component, really annoying.

Regards,

Bart

Former Member
0 Kudos

Hi,

You have created the DataSource and set the parameters on the 'Main Tab', just open the 'Additional Tab' and check if the SQL Engine parameter is set to 'Vendor SQL' and not 'Open SQl'.

Hope that helps.

Regards,

S.Divakar

Former Member
0 Kudos

Yes, it works now!

Still I want to know why the second option does not work,

but now I can proceed with the development!

Thanks !!!!

Former Member
0 Kudos

I would like to create Drivers and DataSources for oracle and sqlserver. Where do I get the driver jars from?

Former Member
0 Kudos

You can download them from the corresponding website (e.g. mysql). Just check the version you use!

Former Member
0 Kudos

Thx. Found driver for Oracle and MsSql. Great!

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Sir I have same problem i want to connect to the oracle through web dynpro.

i am developing application for Guest House Management system for company.

Can You Please Give me help on This.

former_member182372
Active Contributor
0 Kudos

Hi Bart,

Check recent topics:

Best regards, Maksim Rashchynski.