title: Rollback not working in jdbc spring programatic transaction
body: <p>Im unable to get a rollback working in my spring (3.0.5) jdbc application, running on Oracle 11.2</p>
  
  <p>When I throw <code>NoClassesException</code> in the Controller below the row inserted by updatedB() remains in the dB.
  I think this is because autoCommit is on (by default) in my dataSource so the commit has already happened and the rollback obviously doesn't work, 
  but I thought the Spring <code>DataSourceTransactionManager</code> handled all this and enforced the rollback?</p>
  
  <p>Interestingly, when i turn autoCommit off in my dataSource ie comment in the :</p>
  
  <pre><code>"defaultAutoCommit" value="false" 
  </code></pre>
  
  <p>and call the commit explicity myself ie comment in:</p>
  
  <pre><code>this.jdbcTemplate.getDataSource().getConnection().commit();
  </code></pre>
  
  <p>nothing happens ie the row is not commited at all,so it looks like i've done something stupid.
  If someone could please point out this mistake I would be very gratefull</p>
  
  <p>My code is :</p>
  
  <pre>
  <code>
  public static void main(String[] args) {
  
          String [] configList ={"database.xml","spring.xml"};
  
          ApplicationContext ctx = new ClassPathXmlApplicationContext(configList);
          cont = (Controller)ctx.getBean("controller");
          cont.transactionTest();
  }
  
  </code>
  </pre>
  
  <p>// Controller , called from Main()</p>
  
  <pre>
  <code>
  public class Controller {
  
      private JdbcTemplate jdbcTemplate;
  
  
      public void transactionTest()
      {       
          int retCode=0;
  
  
          try {
              retCode = updatedB("param1","param2");
              //this.jdbcTemplate.getDataSource().getConnection().commit();
              throw new NoClassesException(); 
          }catch (NoClassesException e){
              System.out.println(e.getMessage() + "2 patents ");
          }
      }
  
      public int updatedB(String param1,String param2 ) 
      {
          int stat = 0;
  
          stat = this.jdbcTemplate.update("INSERT INTO myTable"
                                  + "(param1,param2)"
                                  + " VALUES(?,?)"  , 
                  new Object[] { param1,param2});
  
          return stat;
      }
  
      public JdbcTemplate getJdbcTemplate() {
          return jdbcTemplate;
      }
  
      public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
          this.jdbcTemplate = jdbcTemplate;
      }
  }
  </code>
  </pre>
  
  <pre>
  <code>
  public class NoClassesException extends RuntimeException  {
  
      public NoClassesException() {
          super("Rolled back ");
      }
  }
  </code>
  </pre>
  
  <p>and my spring.xml file is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/aop
      http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
      http://www.springframework.org/schema/tx 
      http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"&gt;
  
  
      &lt;bean id="controller" class="Controller"&gt;
          &lt;property name="jdbcTemplate" ref="jdbcTemplate" /&gt;
      &lt;/bean&gt;
  
  
      &lt;bean id="txManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
      &lt;tx:advice id="txAdvice" transaction-manager="txManager"&gt;
          &lt;tx:attributes&gt;
              &lt;tx:method name="transaction*" propagation="REQUIRED" rollback-for="NoClassesException" /&gt;
              &lt;tx:method name="update*" propagation="SUPPORTS" /&gt;
              &lt;tx:method name="*" propagation="SUPPORTS" read-only="true" /&gt;
          &lt;/tx:attributes&gt;
      &lt;/tx:advice&gt;
  
  
  
      &lt;aop:config&gt;    
          &lt;aop:pointcut id="myMethods" expression="execution(* *..Controller.*(..))" /&gt;
          &lt;aop:advisor advice-ref="txAdvice" pointcut-ref="myMethods" /&gt;
      &lt;/aop:config&gt;
  
  
  
      &lt;bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>and my database.xml file is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
      http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/aop
      http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
      http://www.springframework.org/schema/tx 
      http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"&gt;
  
  
  
      &lt;bean id="dataConfigPropertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
          &lt;property name="searchSystemEnvironment" value="true" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
          &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
          &lt;property name="initialSize" value="2" /&gt;
          &lt;property name="maxActive" value="2" /&gt;
  
          &lt;property name="url" value="my connection details" /&gt;
          &lt;property name="username" value="xxx" /&gt;
          &lt;property name="password" value="xxx" /&gt;
          &lt;!-- &lt;property name="defaultAutoCommit" value="false" /&gt; --&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>