cancel
Showing results for 
Search instead for 
Did you mean: 

problem with DataSource

Former Member
0 Kudos

hi,

i have written the code for getting data from maxdb.But it is giving error.pls hel me

	Properties p = new Properties();

							p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
                                                                                p.put(Context.PROVIDER_URL, "192.168.1.2:50004");

							p.put(Context.SECURITY_PRINCIPAL, "admin");

							p.put(Context.SECURITY_CREDENTIALS, "admin");

				InitialContext ctx=null;
		String test="1";		
 	try {
 			ctx = new InitialContext(p);
	 	Object o=ctx.lookup("jdbc/SAPJ2EDB");




<i><b>Error</b></i>

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)

at java.net.URLClassLoader.access$100(URLClassLoader.java:55)

at java.net.URLClassLoader$1.run(URLClassLoader.java:194)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:187)

at java.lang.ClassLoader.loadClass(ClassLoader.java:289)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)

at java.lang.ClassLoader.loadClass(ClassLoader.java:235)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:219)

at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)

at javax.naming.spi.NamingManager.getObjectFactoryFromReference(NamingManager.java:129)

at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:299)

at com.sap.engine.services.jndi.implclient.ClientContext.lookup(ClientContext.java:497)

at com.sap.engine.services.jndi.implclient.ClientContext.lookup(ClientContext.java:614)

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

at ForFoundation.main(ForFoundation.java:42)

Exception in thread "main"

regards

Guru

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try with the following code snippet to access the DataSource using the JNDI look up name:

try{

InitialContext initialContext = new InitialContext();

DataSource dataSource = (DataSource)initialContext.lookup("jdbc/SAPJ2EDB");

java.sql.Connection conn = dataSource.getConnection();

Statement st = conn.createStatement();

....

...

}

Hope this helps.

Regards,

Srinivasan T

<b>Helpful answer=>points</b>

Former Member
0 Kudos

hi

i have done wht u have said and i have added some jars also .

exception is

java.lang.NoClassDefFoundError: iaik/utils/Base64Exception

at com.sap.sql.connect.OpenSQLConnectInfo.getStore(OpenSQLConnectInfo.java:802)

at com.sap.sql.connect.OpenSQLConnectInfo.lookup(OpenSQLConnectInfo.java:787)

at com.sap.sql.connect.OpenSQLDataSourceImpl.setDataSourceName(OpenSQLDataSourceImpl.java:206)

at com.sap.sql.connect.OpenSQLDataSourceImpl.setDataSourceName(OpenSQLDataSourceImpl.java:194)

at com.sap.engine.services.dbpool.spi.ManagedConnectionFactoryImpl.createManagedConnection(ManagedConnectionFactoryImpl.java:113)

at com.sap.engine.services.dbpool.spi.DefaultConnectionManagerImpl.allocateConnection(DefaultConnectionManagerImpl.java:26)

at com.sap.engine.services.dbpool.cci.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:51)

at ForFoundation.main(ForFoundation.java:49)

Exception in thread "main"

regards

Guru

Former Member
0 Kudos

Hi,

In the DataSource created in Visual Administrator, it seems you have given the SQL Engine as 'open'. Change it to 'Vendor' and then rebuild/redeploy your application.

Regards,

Srinivasan T

<b>Helpful answer=>points</b>

Former Member
0 Kudos

hi,

Vendor means sap.com or any thing. can write directly like Vendor_sql in value of sql engin.

pls tell me .

regards

Guru

Former Member
0 Kudos

Hi,

As you are using Oracle, click on the radiobutton 'Vendor' in the step I said above. No need of writing Vendor_sql in the sql engine.

Regards,

Srinivasan T

Former Member
0 Kudos

hi,

what is diff b/w

opensql

nativesql

vendorsql in sql engine

regards

Guru

Former Member
0 Kudos

Hi,

two helpful sources that explain it:

an <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/05058e8d-0c01-0010-c986-fdc8eaebf37c">article</a>, and <a href="http://help.sap.com/saphelp_nw04/helpdata/en/2d/23b32e8c0152469edf07909703fe03/frameset.htm">documentation</a>.

Former Member
0 Kudos

hi

how to registere drivers on the SAP J2EE Engine.

regards

Guru

Former Member
0 Kudos

Hi,

the article that I gave link to in the previous message contains an overview of the options that you have for deploying the drivers on the server. Please, refer to section Common Tasks -> Deploying a JDBC Driver of this article for info about deploying the driver libraries using the Telnet console.

You can also do it with Visual Administrator as described <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/80/4f34c587f05048adee640f4c346417/frameset.htm">here</a>.

Hope that helps!

Former Member
0 Kudos

hi,

can i use mysql database for entity bean instead of maxdb.

can i deploy dictionary objects my sql

regards

Guru

Former Member
0 Kudos

Hi,

on the first question: yes, you can, but the DataSource you should use for connectivity should be using Vendor SQL.

second question: no, you can't. Java dictionary and Open SQL can be used with the system's database (note, this does not include MaxDB only; this is true for all DBs that are supported as listed in the product availability matrix: http://service.sap.com/pam). Since mysql is not among supported DBs, you cannot use java dictionary with it..

Hope that explains this a bit.