Where The Streets Have No Name

Getting a Connection from an Application-Scoped Connection Pool(웹로직) 본문

Developement/Java

Getting a Connection from an Application-Scoped Connection Pool(웹로직)

highheat 2006. 4. 24. 17:39

To get a connection from an application-scoped connection pool, you look up the data source defined in the weblogic-application.xml descriptor file in the local environment (java:comp/env) and then request a connection from the data source. For example:

javax.sql.DataSource ds = 
(javax.sql.DataSource) ctx.lookup("java:comp/env/myDataSource");
java.sql.Connection conn = ds.getConnection();

When you are finished using the connection, make sure you close the connection to return it to the connection pool:

conn.close();