cancel
Showing results for 
Search instead for 
Did you mean: 

Connection to MaxDB via JDBC

Former Member
0 Kudos

Hi,

I have a problem with the connection to my database MaxDB.

I created a JDBC Connector in the Visual Administrator.

Now I try to connect to the database from my ejb project.

I try it with the following statement

InitialContext ctx = new InitialContext();

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

Here I got the error message:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)

at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)

at javax.naming.InitialContext.lookup(InitialContext.java:347)

at myspv.com.connectors.SAPDBConnector.getManagedOracleDBConnection(SAPDBConnector.java:46)

at myspv.com.connectors.SAPDBConnector.main(SAPDBConnector.java:54)

Now, after reading some sdn entries, I try it with the following statement:

Properties p = new Properties();

p.put(InitialContext.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");

p.put(InitialContext.PROVIDER_URL, "localhost:50004");

InitialContext ctx = new InitialContext(p);

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

But I got again an error:

java.lang.NoClassDefFoundError: javax/resource/ResourceException

at java.lang.ClassLoader.defineClass0(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:539)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)

Could anyone explain me what the error are and what is the solution for each error?

Thanks a lot.

Nils

Accepted Solutions (1)

Accepted Solutions (1)

sivasatyaprasad_yerra
Active Contributor
0 Kudos

.Jar file is missing which contains the package javax/resource/ResourceException.

Check it in www.docjar.com for the jar file which contains this package and download the correct jar file and place it in lib folder of your project.

Reward points if useful

Regards,

Siva.

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

>

> .Jar file is missing which contains the package javax/resource/ResourceException.

> Check it in www.docjar.com for the jar file which contains this package and download the correct jar file and place it in lib folder of your project.

>

> Reward points if useful

> Regards,

> Siva.

Well Siva,

this is really... far away from anything like a solution.

For this you only can get negative points.

Regards,

Benny

Former Member
0 Kudos

Hi Benny,

thanks for your answer.

I regarded and also reconstructed the assistance but I get yet the first error message

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)

at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)

at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)

at javax.naming.InitialContext.lookup(InitialContext.java:347)

at myspv.com.connectors.SAPDBConnector.getManagedOracleDBConnection(SAPDBConnector.java:46)

at myspv.com.connectors.SAPDBConnector.main(SAPDBConnector.java:54)

I created a JDBC Connector and JMS Connector.

Thanks

Nils

Former Member
0 Kudos

Hi,

To resolve

"javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial"

add the following jar PRTJNDISUPPORT.JAR from your eclipse folder.

Regards

Ayyapparaj

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

Nils,

in the manuals, where those things are explained, there are examples also. Can you run those?

Regards,

Benny

Former Member
0 Kudos

Thanks a lot.

Now it works.

Nils

Answers (1)

Answers (1)

Benny
Product and Topic Expert
Product and Topic Expert
0 Kudos

How about some reading in the docs?

[Getting a Connection to the Database|http://help.sap.com/saphelp_nw70/helpdata/en/82/fdbf2085f65f43a71e755fc904478d/frameset.htm] or

[Relational Persistence|http://help.sap.com/saphelp_nw70/helpdata/en/b8/092492099b7c44b266c3128624076e/frameset.htm]

That should help....

BTW: Your second try is completely off the records.