<Context>
<Resource name="jdbc/postgres" auth="Container"
Type="javax.sql.DataSource" driverClassName="org.postgresql.Driver".
Url="jdbc:postgresql://127.0.0.1:5432/mydb".
Username="myuser" password="mypasswd" maxActive="20" maxIdle="10".
MaxWait="-1"/>.
</Context>
web.xml configuration.
<resource-ref>
<description>postgreSQL Datasource example</description>
<description>postgreSQL <res-ref-name>jdbc/postgres</res-ref-name>
<res-ref-name>jdbc/postgres</res-ref-name> <res-type>javax.sql.DataSource</res-type>
<res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth>
<resource-ref> </resource-ref>
________________.
InitialContext cxt = new InitialContext();.
if ( cxt == null ) {
Throw new Exception("Uh oh -- no context!");.
}.
DataSource ds = (DataSource) cxt.lookup( "java:/comp/env/jdbc/postgres" );.
if ( ds == null ) {
Throw new Exception("Data source not found!");.
}.