Java Mailing List Archive

http://www.java2.5341.com/

Home » user-java.ibatis »

committing stored procedure

Mr.Squirrel

2010-06-04

Replies:

Author LoginPost Reply

Hi there,

How to make a commit when calling a stored procedure which make an insert :
This commit doesn't work :

public void insererCiv1() {
 try {
     
 Adresse autreAdresse = new Adresse();
 autreAdresse.setCodEtudiant("09F643X");
 autreAdresse.setCodTypAdresse("1");
 autreAdresse.setTel("0240281365");
 autreAdresse.setComplement("c2");
 autreAdresse.setNum("1");
 autreAdresse.setVoie("2");
 autreAdresse.setLocalite("paris");
 autreAdresse.setCp("75000");
 autreAdresse.setVille("paris");
 autreAdresse.setPays("100");
 
this.getSqlMapClient().startTransaction();
this.getSqlMapClient().queryForObject("pAdresse", autreAdresse); // call
stored procedure which make an insert
this.getSqlMapClient().commitTransaction();

 } catch (SQLException e) {
     System.out.println(e);
 } finally{
      try {
         this.getSqlMapClient().endTransaction();
       } catch (SQLException e) {
       }
    }    
 }

sqlMap.xml (stored procedure making an insert)
...
<procedure id="pAdresse" parameterMap="adresseParamMap">
  { call pbw_adresse.MajAdresse(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }
</procedure>

SpringConfiguration.xml :
...
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
   destroy-method="close">
   <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"
/>
   <property name="url" value="jdbc:oracle:thin:@(protected)" />
   <property name="username" value="***" />
   <property name="password" value="***" />
   <property name="validationQuery" value="SELECT 1 FROM DUAL" />
   <property name="testOnBorrow" value="true" />
   <property name="defaultAutoCommit" value="false" />
 </bean>

 <bean id="sqlMapClientTemplate"
class="org.springframework.orm.ibatis.SqlMapClientTemplate">
   <property name="sqlMapClient">
     <bean class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
       <property name="configLocation">
         <value>classpath:fr/univNantes/sig/swelPrimo/ibatis/SqlMapConfig.xml
         </value>
       </property>
       <property name="dataSource">
         <ref bean="dataSource" />
       </property>
       <property name="transactionConfigClass">
       
<value>com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransactionConfig</value>
       </property>        
     </bean>
   </property>
 </bean>
 
Thanks

Fran├žois
--
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@(protected)
For additional commands, e-mail: user-java-help@(protected)

©2008 java2.5341.com - Jax Systems, LLC, U.S.A.