File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI on startup

 
karthik kesan
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to load my JNDI datasource before the startup servlet,becacuse in startupservlet I am having some code which loads some values from the database.

I am using the lookup code to get the JNDI name ,but it is not finding that name.


web.xml code added this code after taglibs definitions
<resource-ref>
<description>Primary database</description>
<res-ref-name>jdbc/wbol</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

sun-web.xml code
<resource-ref>
<res-ref-name>jdbc/wbol</res-ref-name>
<jndi-name>jdbc/wbol</jndi-name>
</resource-ref>

java code:
initContext = new InitialContext();
source = (DataSource) initContext.lookup ("java:comp/env/jdbc/wbol");

can anyone help me out to resolve this issue.
 
Carl Trusiak
Sheriff
Posts: 3340
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to configure the JNDI Data Source in the Admin application for the server.
http://docs.sun.com/source/819-0076/jdbc.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic