org.apache.commons.dbcp.BasicDataSource and JasperReports
koszta5Dec 23 2010 — edited Dec 24 2010Hi folks,
I am creating some jasper reports from our database. I am using commons library and spring framework...
I have a bean declaration in applicationContext.xml
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="${database.driverClassName}"/>
<property name="url" value="${database.url}"/>
<property name="username" value="${database.username}"/>
<property name="password" value="${database.password}"/>
<property name="validationQuery" value="SELECT 1 FROM DUAL"/>
<property name="testOnBorrow" value="true"/>
</bean>
This bean connects me to our database. Now I would love to use this class for connection in my Jasperreport creating class (not establishing a new connection but getting my existing AND configured bean). I can create a new BasicDataSource BUT that is not configured.
Is there a way for me to get my configured bean in my java code ?