Skip to Content
author's profile photo Former Member
Former Member

JNDI Lookup Of JDBC Connector from a Servlet

Dear all:

I have created a Oracle JDBC Connector (using J2EE Visual

admin). Its Application name is "sap.com/JDBCConnector_xi.xml" and its name is

"xi"

In my servlet I have the following code

"

ic = new InitialContext() ;

DataSource ds = (DataSource) ic.lookup

("jdbc/ourLookup");

"

During deployment (J2EE Components and Assembler

tab) I have entered the following:

Resource Name = jdbc/ourLookup

Resource Type = javax.sql.DataSource

Authorization Type = Application

Resource Sharing = Shareable

In the deployer tab (after connecting to the J2EE

Engine) in the Environment tab/Resource References I

given the following:

Resource Name = jdbc/ourLookup

Resource Type = javax.sql.DataSource

Authorization Type = Application

Resource Sharing = Shareable

Resource Link = xi

After clicking on "Make All" I have found that

web.xml and web-j2ee-engine.xml are created

and they have the following entries in them:

web.xml

-


<resource-ref>

<res-ref-name>alias1</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

<res-sharing-scope>Shareable</res-sharing-scope>

</resource-ref>

web-j2ee-engine.xml

-


<resource-ref>

<res-ref-name>alias1</res-ref-name>

<res-link>xi</res-link>

</resource-ref>

But when the application runs I get a Persistent error

that NameNotFound Exception.

I would request any help from you. My email id is

caesar.dutta@in.pwc.com or caesardutta@yahoo.com

Thanks very much in advance.

Regards,

Caesar

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Feb 23, 2005 at 07:44 AM

    Hi Ceasar,

    as you have declared a resource reference to the DataSource and you are looking it up from a servlet, you have to perform the lookup relative to the java:comp/env context. That is, you should use

    DataSource ds = (DataSource) ic.lookup

    ("java:comp/env/jdbc/ourLookup");

    See also an example of looking up a DataSource for the default DataSource on the J2EE Engine: http://help.sap.com/saphelp_nw04/helpdata/en/7d/26e96f1d754408bfd658b6614cb1b6/frameset.htm

    Hope that helps!

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.