So i have an applicationContext.xml which has a bean dataSource defined in it.
<bean id="dataSource" class="org.apache.commons.....">
<bean id="testDao" class="com.testDao">
<property name="dataSource" ref="dataSource"/>
Now in my testDao i had the dataSource :-
private DataSource dataSource;
setters and getter for the datasource. Now in one of my method when i try to get connection from the dataSource it's always coming null. Any clue why is it doing that ?
Connection conn = null;
conn = getDataSource().getConnection();
I get a nullpointer exception in this statement, hence my queries don't get executed. Can anyone tell me how to get the connection instance from the dataSource ?