Results 1 to 8 of 8

Thread: Executing multiple stored procedure from a single class

  1. #1

    Default 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. #2
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    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).

  3. #3

    Default

    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.

  4. #4
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    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?

  5. #5
    Join Date
    Aug 2004
    Posts
    1,107

    Default

    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.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  6. #6

    Default

    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.

  7. #7
    Join Date
    Jan 2013
    Posts
    5

    Default 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...

    Quote 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.

  8. #8
    Join Date
    Jan 2013
    Posts
    5

    Default 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 @ pearsolivia@gmail.com....







    Quote 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...

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. Replies: 3
    Last Post: Sep 4th, 2005, 11:11 PM
  5. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •