Skip to Content
Former Member
May 27, 2008 at 10:32 AM

Connect to SAP database using Java?


Hello All,

My requirement is to connect to a SAP database using the Java Application. As per the information i have, We can create a Data dictionary using the SAP Netweaver. Accordingly i have created a data dictionary and deployed the sda file on the portal. Now i need to connect to that database using java jndi.

my database connection class has the foll code:

InitialContext ctx = new InitialContext();

DataSource dataSource = (DataSource) ctx.lookup("java:comp/env/TMP_MEGHANA");

con = dataSource.getConnection();

I get the error: 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

I am not sure where exactly do i have to specfy TMP_MEGHANA to be considered as a datasource.

Could some1 let me know how do i go about this problem?

Thanks in advance,