Thursday, March 27, 2008

what is use of resource-ref Element in web.xml?

The optional resource-ref element defines a reference lookup name to an external resource. This allows the servlet code to look up a resource by a "virtual" name that is mapped to the actual location at deployment time.

Use a separate <resource-ref> element to define each external resource name. The external resource name is mapped to the actual location name of the resource at deployment time in the WebLogic-specific deployment descriptor weblogic.xml.

 

 

 

By using <resource-ref> in web.xml like:-

<resource-ref>
<resource-ref-name> jdbc/dbase </resource-ref-name>
<resource-ref-type> javax.sql.DataSource </resource-ref-type>
<resource-ref-auth> container </resource-ref-auth>
</resource-ref>

In .java file

// No database info in it like driver,db url, username & password
(DataSource) ds=(DataSource)ctx.lookup("jdbc/dbase");

Here i know that by using DataSource we are actually creating a pool of connection objects from that we are proceeding further.

 

No comments:

Post a Comment