bg left bg right
      
  |  | 
Welcome to SleepyEgg Tech News and Coupon Deals!
useful tools from Apache Jakata Commons - dbcp PDF Print E-mail
(0 votes)
Written by Sleepy Egg   
Monday, 27 June 2005
dbcp is an implementation of Java connection pooling. This uses the common-pooling API. You can implement a generice Database class to wrap both JDBC connection pooling using dbcp and datasource looking using JNDI. Once this is done, you don't have to care about how it gets the connection from. example: for connection pooling using dbcp : http://cvs.apache.org/viewcvs.cgi/jakarta-commons/dbcp/doc/BasicDataSourceExample.java?rev=1.2&view=markup BasicDataSource ds = new BasicDataSource(); ds.setDriverClassName("oracle.jdbc.driver.OracleDriver"); ds.setUsername("scott"); ds.setPassword("tiger"); ds.setUrl(connectURI); return ds; BasiceDataSource is a subclass of DataSource. So doesn't matter if it is from JNDI lookup or from dbcp, cache it. The only method you need to implement is getConnection(), which get connection from the datasource.


Comments (0)add comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley

security image
Write the displayed characters


busy
 


Valid XHTML 1.0 Transitional