Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Context>
- <Resource name="jdbc/BookStoreDB"
- auth="Container"
- type="javax.sql.DataSource"
- driverClassName="com.mysql.jdbc.Driver"
- url="jdbc:mysql://localhost:3306/BookStoreDB" />
- </Context>
- <resource-ref>
- <res-ref-name>jdbc/BookStoreDB</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- </resource-ref>
- <context-param>
- <param-name>DATABASE_NAME</param-name>
- <param-value>jdbc/BookStoreDB</param-value>
- </context-param>
- Context initCtx = new InitialContext();
- Context envCtx = (Context) initCtx.lookup("java:comp/env");
- DataSource ds = (DataSource) envCtx.lookup(name); //name ััะพ DATABASE_NAME
- connection = ds.getConnection();
Add Comment
Please, Sign In to add comment