Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- context.xml:
- <?xml version="1.0" encoding="UTF-8"?>
- <Context antiJARLocking="true" path="/openbankof">
- <Resource name="jdbc/bankofds" auth="Container" type="javax.sql.DataSource"
- maxActive="100" maxIdle="30" maxWait="10000"
- username="app"
- password="app"
- driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
- url="jdbc:derby:c:/temp/datosbankof"/>
- </Context>
- web.xml:
- <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
- http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
- version="2.4">
- <description>MySQL Test App</description>
- <resource-ref>
- <description>DB Connection</description>
- <res-ref-name>jdbc/bankofds</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- </resource-ref>
- </web-app>
- *.java:
- Context initContext = new InitialContext();
- Context envContext = (Context)initContext.lookup("java:/comp/env");
- DataSource ds = (DataSource)envContext.lookup("jdbc/bankofds");
- Connection conn = ds.getConnection();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement