Announcement Announcement Module
Collapse
No announcement yet.
Transaction unable to Rollback Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction unable to Rollback

    HI every one,
    I am trying to implement Declarative Transaction Management using JDBC and my transaction is not rolling back when an exception occurs. Please check what i am doing is right or not.


    My Interface contains methods and there implementation is in DImpl. I get bean from spring frame work in main of my implementation class and call function procWithStringOnly which uses OStoredProcedure to execute a stored procedure. After executing a stored procedure i call a method which throws Exception and ctach it in the same method that executes stored procedure. My Application Context says if the method throws UnsupportedOperationException the transaction should be rolled back, but it throws exception and at the same time transaction also gets committed. Please guide me where i am wrong i will be very thank ful.

    Application Context.xml
    <code>
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING/DTD BEAN/EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <bean id="testClassTarget" class="Do.DImpl">
    </bean>

    <bean id="DInterface" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="proxyInterfaces">
    <list>
    <value>
    Do.DInterface
    </value>
    </list>
    </property>
    <property name="target">
    <ref bean="testClassTarget"/>
    </property>
    <property name="transactionManager">
    <ref bean="txManager"/>
    </property>
    <property name="transactionAttributeSource">
    <ref bean="attributeSource"/>
    </property>
    </bean>

    <bean id="attributeSource" class="org.springframework.transaction.interceptor .NameMatchTransactionAttributeSource">
    <property name="properties">
    <props>
    <prop key="procWithStringOnly">
    PROPAGATION_REQUIRED, -UnsupportedOperationException
    </prop>
    </props>
    </property>
    </bean>

    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
    </bean>

    <bean id="dDataSource " class="Test.DDataSource">
    <property name="dataSource">
    <ref local="dataSource"></ref>
    </property>
    </bean>


    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource" destroy-method="close">
    <property name="driverClassName">
    <value>oracle.jdbc.driver.OracleDriver</value>
    </property>
    <property name="url">
    <value>jdbc:oracle:thin:@192.168.0.211:1521:ONCDB1 </value>
    </property>
    <property name="username">
    <value>Test</value>
    </property>
    <property name="password">
    <value>Test</value>
    </property>
    </bean>
    </beans>
    </code>

    My Interface
    <code>
    package Do;
    import org.springframework.context.ApplicationContext;

    public interface DInterface
    {
    public void procWithStringOnly();
    public void setAppContext(ApplicationContext apctx);
    public void TestTransaction();
    }
    </code>


    My Implementation Class
    <code>
    package Do;
    import java.sql.Types;
    import java.util.Hashtable;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlAp plicationContext;
    import org.springframework.jdbc.core.SqlOutParameter;
    import org.springframework.jdbc.core.SqlParameter;
    import Test.OStoredProcedure;

    public class DImpl implements DInterface
    {
    ApplicationContext applicationContext = null;
    public void procWithStringOnly()
    {
    Hashtable procParamsTypes = new Hashtable();
    Hashtable procParams = new Hashtable();
    String strVal = "11551'1001100000''TALAL''AHMED''''123 ROAD SIDE''07009''NJ''CEDAR GROVE''''M''(434)324-3242''''1966/02/16'''''8443056100'2007/05/26'3'1210''1215'''''84430561'1444''3621'' 1'01";
    String loginType = "1";

    procParamsTypes.put("1", new SqlParameter("strVal", Types.VARCHAR));
    procParamsTypes.put("2", new SqlParameter("loginType", Types.VARCHAR));
    procParamsTypes.put("3", new SqlOutParameter("returnArray", Types.VARCHAR));
    procParamsTypes.put("4", new SqlOutParameter("patientID", Types.VARCHAR));
    procParamsTypes.put("5", new SqlOutParameter("slotAllocationID", Types.VARCHAR));
    procParams.put("1", strVal);
    procParams.put("2", loginType);
    OStoredProcedure osp = new OStoredProcedure();
    osp.executeStoredProcedure("SCHL_APPOINTMENTS.inse rt", procParamsTypes, procParams, applicationContext);
    try
    {
    this.TestTransaction();
    }
    catch(UnsupportedOperationException uoe)
    {
    System.out.println("Please Rollback the transaction..........");
    }

    }

    public void TestTransaction()
    {
    throw new UnsupportedOperationException();
    }
    public void setAppContext(ApplicationContext apctx)
    {
    this.applicationContext = apctx;
    }

    public static void main(String[] str1)
    {
    ApplicationContext appContext = new ClassPathXmlApplicationContext (
    new String [] { "applicationContext.xml" } );

    DInterface di = (DInterface) appContext.getBean("DInterface");
    di.setAppContext(appContext);
    di.procWithStringOnly();
    }

    }
    </code>


    My OStoredProcedure Class
    <code>
    package Test;
    import java.sql.CallableStatement;
    import java.sql.Types;
    import java.util.HashMap;
    import java.util.Hashtable;
    import java.util.Map;
    import oracle.jdbc.OracleTypes;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlAp plicationContext;
    import org.springframework.jdbc.core.SqlOutParameter;
    import org.springframework.jdbc.core.SqlParameter;
    import org.springframework.jdbc.object.StoredProcedure;

    public class OStoredProcedure extends StoredProcedure
    {


    public OStoredProcedure()
    {
    }

    public void executeStoredProcedure(String procName, Hashtable procParamsTypes, Hashtable procParams, ApplicationContext appContext)
    {
    Map inParams = new HashMap(2);
    try
    {
    setDataSource(((DDataSource)appContext.getBean("dD ataSource")).getDataSoutce());
    setSql(procName);
    }
    catch(Exception ex)
    {
    ex.printStackTrace();
    }
    for(int i=1; i<=procParamsTypes.size();i++)
    {
    try
    {
    Class cSqlOutParameter = Class.forName("org.springframework.jdbc.core.SqlOu tParameter");
    Class cSqlParameter = Class.forName("org.springframework.jdbc.core.SqlPa rameter");
    if(cSqlOutParameter.isInstance(procParamsTypes.get (i+"")))
    {
    System.out.println("in if");
    declareParameter((SqlOutParameter) procParamsTypes.get(i+""));
    }
    else if(cSqlParameter.isInstance(procParamsTypes.get(i+ "")))
    {
    System.out.println("in else");
    declareParameter((SqlParameter) procParamsTypes.get(i+""));
    inParams.put(((SqlParameter) procParamsTypes.get(i+"")).getName(), procParams.get(i+"").toString());
    }
    }
    catch(ClassNotFoundException cnfe)
    {
    cnfe.printStackTrace();
    }
    }
    compile();

    Map outParams = execute(inParams);
    if (outParams.size() > 0) {
    String[] str1 = null;
    System.out.println("Yes got return values");
    } else {
    System.out.println("have nothing");
    }
    }
    }
    </code>

  • #2
    The problem here is that the transaction doesn't pass through the transaction boundary hence it can't be rolled back. Coupled with that internal method calls aren't proxied using Spring AOP, hence that can't trigger rollback either. You'd have to throw the exception from the DAO method to trigger rollback, call rollback programmatically or use AspectJ which can proxy internal calls.
    http://www.springframework.org/docs/...decl-explained
    http://www.springframework.org/docs/...ng-aop-proxies

    It really helps to post code in [code] [ /code] tags as well, it's soooo much easier to read.
    Last edited by karldmoore; Aug 30th, 2007, 05:49 AM.

    Comment


    • #3
      Hi karldmoore,
      Thanks for replying. Sir, i have a confusion which i want to make clear. I am trying to implement transaction using Declarative Transaction Management. I want to use jdk 1.4. Is it possible to use? After reading your reply i tried to implement the transaction as described in the document but it asks me to change jdk to 1.5 and i dont want it. I want to implement it in 1.4.

      Regards,
      Mohsin.

      Comment


      • #4
        Yes you can use 1.4, which part of it suggested that you couldn't?
        Last edited by karldmoore; Aug 30th, 2007, 05:49 AM.

        Comment


        • #5
          Following is my ApplicationContext.xml
          Code:
          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:aop="http://www.springframework.org/schema/aop"
                 xmlns:tx="http://www.springframework.org/schema/tx"
                 xsi:schemaLocation="
                 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
                 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
          
          <beans>
          
          <!-- this is the service object that we want to make transactional -->
          <bean id="dInterface" class="Do.DImpl"/>
          
          <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
            <tx:advice id="txAdvice" transaction-manager="txManager">
              <!-- the transactional semantics... -->
              <tx:attributes>
                <!-- other methods use the default transaction settings (see below) -->
                <tx:method name="procWithStringOnly"/>
              </tx:attributes>
            </tx:advice>
          
          <!-- ensure that the above transactional advice runs for any execution
                of an operation defined by the FooService interface -->
            <aop:config>
              <aop:pointcut id="dInterfaceOperation" expression="execution(* Do.DInterface.*(..))"/>
              <aop:advisor advice-ref="txAdvice" pointcut-ref="dInterfaceOperation"/>
            </aop:config>
          
          <bean id="dDataSource " class="Test.DDataSource">
             <property name="dataSource">
               <ref local="dataSource"></ref>
             </property>
          </bean>
          
          <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
            <property name="driverClassName">
              <value>oracle.jdbc.driver.OracleDriver</value>
            </property>
            <property name="url">
              <value>jdbc:oracle:thin:@192.168.0.211:1521:ONCDB1</value>
            </property>
            <property name="username">
              <value>Test</value>
            </property>
            <property name="password">
              <value>Test</value>
            </property>
          </bean>
          
          <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
             <property name="dataSource" ref="dataSource"/>
          </bean>
          </beans>

          Following is the exception i am getting
          Code:
          Exception in thread main
          org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from class path resource [applicationContext.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.crimson.jaxp.DocumentBuilderFactoryImpl@13] does not support XML Schema. Are you running on Java 1.4 or below with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
          
          Caused by: javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [org.apache.crimson.jaxp.DocumentBuilderFactoryImpl@13] does not support XML Schema. Are you running on Java 1.4 or below with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
          
          	at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:101)
          
          	at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
          
          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:351)
          
          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
          
          	at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
          
          	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
          
          	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
          
          	at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:173)
          
          	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:112)
          
          	at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
          
          	at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:100)
          
          	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:298)
          
          	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)

          Comment


          • #6
            There appears to be an option here "Upgrade to Apache Xerces (or Java 1.5) for full XSD support".
            Last edited by karldmoore; Aug 30th, 2007, 05:49 AM.

            Comment


            • #7
              This error came up a few times on the forum:
              http://forum.springframework.org/showthread.php?t=21140
              http://forum.springframework.org/showthread.php?t=36614

              Comment


              • #8
                Hi,
                First of all thanks Andrei Stefan and thanks a lot Karldmoore for your continuous help and support. Now, i have fixed the Xerces issue and i am facing another problem. I have prepard my ApplicationContext.xml as shown in the help on following url:-

                http://www.springframework.org/docs/...ansaction.html

                My ApplicationContext.xml is as follows:-
                Code:
                <?xml version="1.0" encoding="UTF-8"?>
                <beans xmlns="http://www.springframework.org/schema/beans"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xmlns:aop="http://www.springframework.org/schema/aop"
                       xmlns:tx="http://www.springframework.org/schema/tx"
                       xsi:schemaLocation="
                       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
                       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
                
                
                <!-- this is the service object that we want to make transactional -->
                <bean id="dInterface" class="Do.DImpl"/>
                
                <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
                  <tx:advice id="txAdvice" transaction-manager="txManager">
                    <!-- the transactional semantics... -->
                    <tx:attributes>
                      <!-- other methods use the default transaction settings (see below) -->
                      <tx:method name="procWithStringOnly"/>
                    </tx:attributes>
                  </tx:advice>
                
                <!-- ensure that the above transactional advice runs for any execution
                      of an operation defined by the FooService interface -->
                  <aop:config>
                    <aop:pointcut id="dInterfaceOperation" expression="execution(* Do.DInterface.*(..))"/>
                    <aop:advisor advice-ref="txAdvice" pointcut-ref="dInterfaceOperation"/>
                  </aop:config>
                
                <bean id="dDataSource " class="Test.DDataSource">
                   <property name="dataSource">
                     <ref local="dataSource"></ref>
                   </property>
                </bean>
                
                <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
                  <property name="driverClassName">
                    <value>oracle.jdbc.driver.OracleDriver</value>
                  </property>
                  <property name="url">
                    <value>jdbc:oracle:thin:@192.168.0.211:1521:ONCDB1</value>
                  </property>
                  <property name="username">
                    <value>Test</value>
                  </property>
                  <property name="password">
                    <value>Test</value>
                  </property>
                </bean>
                
                <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                   <property name="dataSource" ref="dataSource"/>
                </bean>
                </beans>

                I am getting following exception:-
                Code:
                org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'DInterface' is defined
                
                	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java)
                
                	at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedBeanDefinition(AbstractBeanFactory.java)
                
                	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
                
                	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
                
                	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:683)
                Please tell me where i am wrong. Thanks a lot once again.

                Mohsin

                Comment


                • #9
                  I suppose that bean is missing :-) and indeed in not on your xml config file.

                  Comment


                  • #10
                    I'd guess it's a case issue, there is a 'dInterface'.
                    Last edited by karldmoore; Aug 30th, 2007, 05:49 AM.

                    Comment


                    • #11
                      Karldmoore, what do you mean by case issue, i am unable to understand? What should i do now, can you please suggest?

                      Comment


                      • #12
                        Sorry I meant the case of the bean name, as in upper case and lower case letters. The exception says it can't find 'DInterface' and your bean is called 'dInterface'. Hence I think you need to change your lookup to 'dInterface'.
                        No bean named 'DInterface' is defined
                        Code:
                        <bean id="dInterface" class="Do.DImpl"/>
                        Last edited by karldmoore; Aug 30th, 2007, 05:49 AM.

                        Comment


                        • #13
                          Thanks Karldmoore,
                          I was looking at the example given on following link
                          http://www.springframework.org/docs/...ansaction.html
                          and in this example it is using interface "FooService" as "fooService" in ApplicationContext.xml so i changed my interface name to "dInterface". However, that problem is resolved now after changing "dInterface" to "DInterface" but still transaction is unable to rollback. Following is the out that i am getting

                          Code:
                          Jun 1, 2007 6:30:04 PM org.springframework.context.support.AbstractApplicationContext refresh
                          
                          INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@e: display name [org.springframework.context.support.ClassPathXmlApplicationContext@e]; startup date [Fri Jun 01 18:30:04 GMT+05:00 2007]; root of context hierarchy
                          
                          Jun 1, 2007 6:30:04 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
                          
                          INFO: Loading XML bean definitions from class path resource [applicationContext.xml]
                          
                          Jun 1, 2007 6:30:06 PM org.springframework.context.support.AbstractApplicationContext refresh
                          
                          INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@e]: org.springframework.beans.factory.support.DefaultListableBeanFactory@29
                          
                          Jun 1, 2007 6:30:06 PM org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
                          
                          INFO: Bean 'org.springframework.aop.config.internalAutoProxyCreator' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
                          
                          Jun 1, 2007 6:30:06 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
                          
                          INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@29: defining beans [DInterface,dDataSource ,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,dInterfaceOperation,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor,dataSource,txManager]; root of factory hierarchy
                          
                          Jun 1, 2007 6:30:06 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
                          
                          INFO: Loaded JDBC driver: oracle.jdbc.driver.OracleDriver
                          
                          i am here
                          
                          in else
                          
                          in else
                          
                          in if
                          
                          in if
                          
                          in if
                          
                          Yes got return values
                          
                          Please Rollback the transaction..........

                          According to my opinion my Stored Procedure inserts data in a table and returns Out Params, i am getting those outparams which i shouldn't get because i am rolling back the transaction after calling procedure. Now my ApplicationContext looks like this:-

                          Code:
                          <?xml version="1.0" encoding="UTF-8"?>
                          <beans xmlns="http://www.springframework.org/schema/beans"
                                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                 xmlns:aop="http://www.springframework.org/schema/aop"
                                 xmlns:tx="http://www.springframework.org/schema/tx"
                                 xsi:schemaLocation="
                                 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                                 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
                                 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
                          
                          <beans>
                          
                          <!-- this is the service object that we want to make transactional -->
                          <bean id="dInterface" class="Do.DImpl"/>
                          
                          <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
                            <tx:advice id="txAdvice" transaction-manager="txManager">
                              <!-- the transactional semantics... -->
                              <tx:attributes>
                                <!-- other methods use the default transaction settings (see below) -->
                                <tx:method name="procWithStringOnly" rollback-for="UnsupportedOperationException"/>
                              </tx:attributes>
                            </tx:advice>
                          
                          <!-- ensure that the above transactional advice runs for any execution
                                of an operation defined by the FooService interface -->
                            <aop:config>
                              <aop:pointcut id="dInterfaceOperation" expression="execution(* Do.DInterface.*(..))"/>
                              <aop:advisor advice-ref="txAdvice" pointcut-ref="dInterfaceOperation"/>
                            </aop:config>
                          
                          <bean id="dDataSource " class="Test.DDataSource">
                             <property name="dataSource">
                               <ref local="dataSource"></ref>
                             </property>
                          </bean>
                          
                          <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
                            <property name="driverClassName">
                              <value>oracle.jdbc.driver.OracleDriver</value>
                            </property>
                            <property name="url">
                              <value>jdbc:oracle:thin:@192.168.0.211:1521:ONCDB1</value>
                            </property>
                            <property name="username">
                              <value>Test</value>
                            </property>
                            <property name="password">
                              <value>Test</value>
                            </property>
                          </bean>
                          
                          <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                             <property name="dataSource" ref="dataSource"/>
                          </bean>
                          </beans>
                          Note: Change is in Bold i.e. added rollback-for attribute

                          Comment


                          • #14
                            Is there a method called procWithStringOnly on DImpl? Does DImpl implement DInterface? Is it possible to see the code you're running?
                            Last edited by karldmoore; Aug 30th, 2007, 05:49 AM.

                            Comment


                            • #15
                              Hi Karldmoore,
                              Here is my code:-

                              My Interface
                              Code:
                              package Do;
                              import org.springframework.context.ApplicationContext;
                              
                              public interface DInterface
                              {
                              public void procWithStringOnly();
                              public void setAppContext(ApplicationContext apctx);
                              public void TestTransaction();
                              }
                              My Implementation Class
                              Code:
                              package Do;
                              import java.sql.Types;
                              import java.util.Hashtable;
                              import org.springframework.context.ApplicationContext;
                              import org.springframework.context.support.ClassPathXmlAp plicationContext;
                              import org.springframework.jdbc.core.SqlOutParameter;
                              import org.springframework.jdbc.core.SqlParameter;
                              import Test.OStoredProcedure;
                              
                              public class DImpl implements DInterface
                              {
                              ApplicationContext applicationContext = null;
                              public void procWithStringOnly()
                              {
                              Hashtable procParamsTypes = new Hashtable();
                              Hashtable procParams = new Hashtable();
                              String strVal = "11551'1001100000''TALAL''AHMED''''123 ROAD SIDE''07009''NJ''CEDAR GROVE''''M''(434)324-3242''''1966/02/16'''''8443056100'2007/05/26'3'1210''1215'''''84430561'1444''3621'' 1'01";
                              String loginType = "1";
                              
                              procParamsTypes.put("1", new SqlParameter("strVal", Types.VARCHAR));
                              procParamsTypes.put("2", new SqlParameter("loginType", Types.VARCHAR));
                              procParamsTypes.put("3", new SqlOutParameter("returnArray", Types.VARCHAR));
                              procParamsTypes.put("4", new SqlOutParameter("patientID", Types.VARCHAR));
                              procParamsTypes.put("5", new SqlOutParameter("slotAllocationID", Types.VARCHAR)); 
                              procParams.put("1", strVal);
                              procParams.put("2", loginType);
                              OStoredProcedure osp = new OStoredProcedure();
                              osp.executeStoredProcedure("SCHL_APPOINTMENTS.inse rt", procParamsTypes, procParams, applicationContext);
                              try
                              {
                              this.TestTransaction(); 
                              }
                              catch(UnsupportedOperationException uoe)
                              {
                              System.out.println("Please Rollback the transaction..........");
                              }
                              
                              }
                              
                              public void TestTransaction()
                              {
                              throw new UnsupportedOperationException();
                              }
                              public void setAppContext(ApplicationContext apctx)
                              {
                              this.applicationContext = apctx;
                              }
                              
                              public static void main(String[] str1)
                              {
                              ApplicationContext appContext = new ClassPathXmlApplicationContext (
                              new String [] { "applicationContext.xml" } ); 
                              
                              DInterface di = (DInterface) appContext.getBean("DInterface");
                              di.setAppContext(appContext);
                              di.procWithStringOnly(); 
                              }
                              
                              }

                              My OStoredProcedure Class
                              Code:
                              package Test;
                              import java.sql.CallableStatement;
                              import java.sql.Types;
                              import java.util.HashMap;
                              import java.util.Hashtable;
                              import java.util.Map;
                              import oracle.jdbc.OracleTypes;
                              import org.springframework.context.ApplicationContext;
                              import org.springframework.context.support.ClassPathXmlAp plicationContext;
                              import org.springframework.jdbc.core.SqlOutParameter;
                              import org.springframework.jdbc.core.SqlParameter;
                              import org.springframework.jdbc.object.StoredProcedure;
                              
                              public class OStoredProcedure extends StoredProcedure
                              {
                              
                              
                              public OStoredProcedure()
                              { 
                              }
                              
                              public void executeStoredProcedure(String procName, Hashtable procParamsTypes, Hashtable procParams, ApplicationContext appContext)
                              { 
                              Map inParams = new HashMap(2); 
                              try
                              {
                              setDataSource(((DDataSource)appContext.getBean("dD ataSource")).getDataSoutce()); 
                              setSql(procName); 
                              }
                              catch(Exception ex)
                              {
                              ex.printStackTrace();
                              } 
                              for(int i=1; i<=procParamsTypes.size();i++)
                              {
                              try
                              {
                              Class cSqlOutParameter = Class.forName("org.springframework.jdbc.core.SqlOu tParameter");
                              Class cSqlParameter = Class.forName("org.springframework.jdbc.core.SqlPa rameter");
                              if(cSqlOutParameter.isInstance(procParamsTypes.get (i+"")))
                              {
                              System.out.println("in if");
                              declareParameter((SqlOutParameter) procParamsTypes.get(i+"")); 
                              }
                              else if(cSqlParameter.isInstance(procParamsTypes.get(i+ "")))
                              {
                              System.out.println("in else");
                              declareParameter((SqlParameter) procParamsTypes.get(i+""));
                              inParams.put(((SqlParameter) procParamsTypes.get(i+"")).getName(), procParams.get(i+"").toString());
                              } 
                              }
                              catch(ClassNotFoundException cnfe)
                              {
                              cnfe.printStackTrace();
                              } 
                              }
                              compile();
                              
                              Map outParams = execute(inParams); 
                              if (outParams.size() > 0) {
                              String[] str1 = null;
                              System.out.println("Yes got return values");
                              } else {
                              System.out.println("have nothing");
                              } 
                              } 
                              }

                              Comment

                              Working...
                              X