Announcement Announcement Module
Collapse
No announcement yet.
Executing multiple stored procedure from a single class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Executing multiple stored procedure from a single class

    Hi,

    I am a newbie to spring.

    I have a Dao bean which is singleton.In this bean class I have getters and setters for stored procedure class.This stored procedure class extends the StoredProcedure.

    At present I have two methods which seperately set the input paramaters and execute the respective stored procedure.When I call these methods with the same instance of the class I get an error saying "Cannot declare paramaters after compiling".

    Is there any way for me to execute multiple stored procedure in a class and let another bean call the methods based on whichever stored procedure it wants to execute.

    Thanks in advance.

  • #2
    What I have typically done in my DAOs is declare a base class stored procedure with all the similar functionality and created subclasses to pass in the StoredProcedure name and override anyting else I need to. In a few other cases I have two classes that have different parameters, but I use a common result set handler (usually a RowMapper or ResultSetExtractor).

    Comment


    • #3
      I tried doing what you said.I created a superclass which executes one stored procedure and another class which extends this class and executes another stored procedure.

      Now when I call both the classes in another class ,I get the same exception "Cannot add parameters once query is compiled ".

      Is there any other way I can achieve my objective.

      Comment


      • #4
        My guess is you are calling compile in the first class and then calling it again in the subclass. You would need to change the code so that compile is only called once. Perhaps you can post the code here?

        Comment


        • #5
          You could create a common abstract base class with all the common code but without the compile option and then create all other classes as subclasses of this class.

          Comment


          • #6
            Actually I was calling the compile in both the classes.

            As suggested I created an abstract class with all the common implementations and just extended it to give specific implementations.

            Thanks everyone for their valuable replies.

            Comment


            • #7
              Help Please....

              Harry, I am tryng to figure out the same thing now.. I have bunch of Stored Procedures and I have to call them thru one generic class..Please help me , I need it damn urgently please...Can you please help me with some code example.

              THanks in Advance...

              Originally posted by trisberg View Post
              You could create a common abstract base class with all the common code but without the compile option and then create all other classes as subclasses of this class.

              Comment


              • #8
                Please Help me

                wpoitras, Please help me with the issue,.. I am new to spring and trying to figure out how to call around 30 stored procs from a generic class.. Please help me... You can email me the code @ [email protected]....







                Originally posted by olivia View Post
                Harry, I am tryng to figure out the same thing now.. I have bunch of Stored Procedures and I have to call them thru one generic class..Please help me , I need it damn urgently please...Can you please help me with some code example.

                THanks in Advance...

                Comment

                Working...
                X