<resource-ref>
<description>Database Connection Pool</description>
<res-ref-name>jdbc/MyDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
envContext.bind("jdbc/MyDB", dataSource);
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource dataSource = (DataSource) envContext.lookup("jdbc/MyDB");
Connection connection = dataSource.getConnection();