Announcement Announcement Module
Collapse
No announcement yet.
How to do connection pooling using spring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to do connection pooling using spring

    Hi,
    I am developing an web application using spring and I have finished the code for calling stored procedure. But now I want to do connection pooling for this application.
    Do i need to add extra code/changes in my DAO classes, or I need to add in applicationContext.xml file?
    Thanx in advance.

  • #2
    You just need to swap out your dataSource for a pooled one. This thread has a couple of examples.
    http://forum.springframework.org/showthread.php?t=33166

    Comment


    • #3
      Thank you, I have made changes you suggested.

      Comment


      • #4
        Not a problem, I'm glad it was useful. Out of interest which connection pool did you go for?

        Comment


        • #5
          I have done it with dbcp.BasicDataSource.
          m I going right? I know very little about spring framework, and I m working on it since last week only. I don't know whatever i m doing is right or wrong !
          This is what i did in my applicationContext.xml

          <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
          <property name="driverClassName">
          <value>com.microsoft.jdbc.sqlserver.SQLServerDrive r</value>
          </property>
          <property name="url">
          <value>jdbc:microsoft:sqlserver://xxxxx;databaseName=xxx;SelectMethod=xxx</value>
          </property>
          <property name="username"><value>xxxx</value></property>
          <property name="password"><value>xxxx</value></property>
          <property name="initialSize"><value>2</value></property>
          <property name="poolPreparedStatements"><value>true</value></property>
          <property name="maxActive"><value>5</value></property>
          <property name="maxIdle"><value>2</value></property>
          </bean>

          I kept rest of my code as it is.
          If i am going wrong please tell me

          Comment


          • #6
            Also I want to ask one question-
            I want multiple ResultSets from my MSSql procedure, How can I get that?
            can u give me any sample code for that?
            Thanx in advance.
            Parag.

            Comment


            • #7
              what do you mean with "multiple ResultSets"?

              Comment


              • #8
                means
                My sql-procedure contains two/more select statements , each statement gives me 5 rows from database.

                Comment


                • #9
                  how would you treat them w/o spring and hibernate?

                  Comment


                  • #10
                    with spring

                    Comment


                    • #11
                      Originally posted by parag View Post
                      I have done it with dbcp.BasicDataSource.
                      m I going right? I know very little about spring framework, and I m working on it since last week only. I don't know whatever i m doing is right or wrong !
                      This is what i did in my applicationContext.xml

                      I kept rest of my code as it is.
                      If i am going wrong please tell me
                      No there's nothing wrong with that I just wondered which connection pool you have decided to go with.

                      Comment


                      • #12
                        Originally posted by Injecteer View Post
                        how would you treat them w/o spring and hibernate?
                        I think what Injecteer was saying is, if you weren't using Spring then how would you write it using normal JDBC. Therefore if you can do it with normal JDBC, it shouldn't be to hard to convert to Spring.
                        Last edited by karldmoore; Mar 2nd, 2007, 12:52 PM. Reason: typo

                        Comment


                        • #13
                          Hi Injecteer,
                          I am sorry i couldn't understand your question. Before using spring I was doing it in servlet by using callableStatement's getMoreResult() method.
                          How can i do it using spring

                          Comment


                          • #14
                            looks like, you have no other option, than using the same technique as before.
                            Here you can forget about Hibernate, as it's support for stored procs is rather useless and actually not recommended at all.

                            Spring can simplify playing with jdbc, but main steps like calling getMoreResult() you'll have to re-program yourself

                            Comment


                            • #15
                              Hey, Thank you for your valuable guidence.
                              Hope I will be getting it in future also.

                              Comment

                              Working...
                              X