title: Spring JDBC transaction manager
body: <p>I try to write a transaction manager using JDBC in Spring.</p>
  
  <p>my app-servlet.xml </p>
  
  <pre><code>&lt;!-- JDBC Config --&gt;
  &lt;bean   id="dataSource" 
          class="org.apache.commons.dbcp.BasicDataSource"
          destroy-method="close" 
          p:driverClassName="${jdbc.driverClassName}"
          p:url="${jdbc.databaseurl}" 
          p:username="${jdbc.username}" 
          p:password="${jdbc.password}" /&gt;
  
  &lt;!-- dataSource TransactionManager --&gt;
  &lt;bean id="transactionManager"
      class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="UserDAOImpl" class="com.project.dao.impl.UserDAOImpl"&gt;
      &lt;property name="transactionManager" ref="transactionManager"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>my UserDAOImpl.java</p>
  
  <pre><code>public class UserDAOImpl implements UserDAO {
  
  //transaction manager
  private DataSourceTransactionManager transactionManager;
  private JdbcTemplate jdbcTemplate;
  
  public UserDAOImpl() {
      super();
      DataSource dataSource = transactionManager.getDataSource();
      jdbcTemplate = new JdbcTemplate(dataSource);
  }
  
  public void setTransactionManager(DataSourceTransactionManager transactionManager)    {
      this.transactionManager = transactionManager;
  }
  ....
  }
  </code></pre>
  
  <p>Even though I have <code>transactionManager</code> Bean in my app-servlet, <code>UserDAOImpl</code> won't be instatiated because <code>transactionManager</code> is <code>null</code>. Probably I miss some point but couldn't find out what is wrong.</p>