Announcement Announcement Module
Collapse
No announcement yet.
Blog - Spring JdbcTemplate: The phantom performance problem Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Blog - Spring JdbcTemplate: The phantom performance problem

    http://karldmoore.blogspot.com/2007/...rformance.html

  • #2
    wondered

    JdbcTemplate does a great job of removing the try/catch/finally/try/catch code we used to write with Jdbc, but under the covers it's just doing the same old stuff we used to do. It's getting hold of a connection, executing a statement, possibly mapping a result set to an object, converting any exceptions for us and releasing the connection. That's pretty much it, it's a thin wrapper around Jdbc that makes it usable in the real world.
    wooh

    .
    If this is set to a high value then typically the connection pool tests will perform slower.
    damn with all this,

    i can see now why the hell after of time my project become slow

    but which would be the solution if i avoid
    jdbctemplate.???

    back to the old habits or hibernate?

    i am saying this coz i use jdbctemplate for jasper reports

    Code:
    private JdbcTemplate jdbcTemplate;
    	
    public void setJdbcTemplate(DataSource dataSource) {
    	this.jdbcTemplate = new JdbcTemplate(dataSource);
    }	
    	
    protected ModelAndView handleRequestInternal(
    		HttpServletRequest request,	
                    HttpServletResponse res)throws Exception{
    			
    	ModelAndView mav = null;
    	try{
    		String query = "";
    		query = "somequery" ;
    				
    		Collection mycollecion = this.jdbcTemplate.query(
    			query ,
    			new Object[]{numdoc},
    			new RowMapper() {
    			public Object mapRow(ResultSet rs, int rowNum) 
                            throws SQLException {
    				WrapClass a = new WrapClass();
    	    					
    				a.setIdnumero(rs.getString("idnumero"));
    				a.setSerie(rs.getString("serie"));
    				a.setTipo(rs.getString("tipo"));
    				a.setIdEmpresa(rs.getString("idEmpresa"));
                                    //more										
    				return a;
    		}
    	});
    
    	JRBeanCollectionDataSource jRBeanCollectionDataSource = new JRBeanCollectionDataSource(mycollecion);
    	Map<String,Object> parameterMap = new HashMap<String,Object>();
    	parameterMap.put("datasource", jRBeanCollectionDataSource);
    	mav = new ModelAndView("somename",parameterMap);
    	}
    	catch(Exception e){
    		logger.info("\n ..... \n"+   e.getMessage() );
    	}			
           return mav;
    }
    good work karl

    regards

    Comment


    • #3
      Setting the initial connection to high should only impact the setup/getting of the first connection, because it is trying to acquire the number of initial connections before returning 1 connection.

      So you might look into another issue imho.

      Comment


      • #4
        Sweet!

        I like that article. But even better, I read on your earlier article "Structured approaches to improving code quality". I didn't know about some of these other tools, like PDM and FindBugs. I'm checking them out as well! I already use Cobertura http://cobertura.sourceforge.net/ for generating coverage reports. Do you know how that compares against emma?

        Comment


        • #5
          Glad you found it useful Greg! I have to confess I've never used cobertura before so it's hard to comment. I've spoken to someone who has and he said there wasn't much in it, he preferred cobertura because the reports looked nicer . It's usually pretty easy to integrate tools like this though so I'd give it a go and see how it works out.
          http://raibledesigns.com/rd/entry/em...rtura_for_code
          http://niftybits.wordpress.com/2007/...rtura-vs-emma/

          Comment


          • #6
            Originally posted by dr_pompeii View Post
            i can see now why the hell after of time my project become slow
            As Marten said I don't think this will be your problem, what dataSource are you using? One important thing to remember is to release your connections, if you are using JdbcTemplate this won't be an issue for you.

            Comment


            • #7
              hello guys

              Setting the initial connection to high should only impact the setup/getting of the first connection, because it is trying to acquire the number of initial connections before returning 1 connection.
              i thought wrong, first time instead all the time, okok

              what dataSource are you using? One important thing to remember is to release your connections, if you are using JdbcTemplate this won't be an issue for you.
              C3PO

              i have already resolved the other problem, was only the maximun ram value for the pool
              i change to 512-memory used by default by OS and other soft = 195 instead 400
              and now the delay is minimum after of a time

              i can breathe in peace

              i remember read in one book, Spring in Action or Pro Spring, that Spring thought to make its own mechanism of persistence, but Hibernate was there and done well its job......

              regards

              Comment


              • #8
                Originally posted by dr_pompeii View Post
                i have already resolved the other problem, was only the maximun ram value for the pool i change to 512-memory used by default by OS and other soft = 195 instead 400 and now the delay is minimum after of a time
                So you've dumped up the RAM and now all your problems have gone away? It would be interesting to see what happens when the load on the application increases.

                Comment


                • #9
                  So you've dumped up the RAM and now all your problems have gone away?
                  yes old value 400 and now 195

                  with 400, only i gave to the pc 115 free, so the swap was high, and all become slow after of time


                  It would be interesting to see what happens when the load on the application increases.
                  i did, after 2hrs testing with the users, the delay after 1hrs was minimum

                  anyway the order to buy 1gb more of ram its done

                  regards karl

                  Comment


                  • #10
                    Originally posted by dr_pompeii View Post
                    i did, after 2hrs testing with the users, the delay after 1hrs was minimum. anyway the order to buy 1gb more of ram its done
                    That's good news anyway. If hardware was the actual problem, it's an easy fix. Let me know how it goes when you add the extra RAM.

                    Comment


                    • #11
                      Hi Karl

                      If hardware was the actual problem, it's an easy fix
                      yeah, thats true in 50%, the other reason was the simple number in the configuration, but thinking in the future always is critical

                      anyway i will create a thread related with minim requeriments

                      regards

                      Comment


                      • #12
                        Originally posted by dr_pompeii View Post
                        yeah, thats true in 50%, the other reason was the simple number in the configuration, but thinking in the future always is critical
                        The extra memory really won't hurt the performance! Out of interest how many users is the application supposed to be serving?

                        Comment


                        • #13
                          Originally posted by gregturn View Post
                          Do you know how that compares against emma?
                          Not that this is really related, but if you are an eclipse user interested in coverage tools, you may also want to look into the wonderful and excellent (IMHO) EclEmma plugin, which uses the EMMA back-end with great Eclipse integration. It provides integrated source-code highlighting in the Eclipse editor.

                          It's one of the best coverage tools I've ever used to help a developer actually improve code coverage, because it's so easy to see where you missed code. Yes, a lot of the other tools generate similar static HTML reports with source code highlighting, but it's sooo much better having the actual source code highlighted! Whoever is responsible for developing and maintaining EclEmma gets a big gold star from me

                          Comment


                          • #14
                            The extra memory really won't hurt the performance!
                            i dont understand your expression,
                            is not true that more ram can help the performance of the pc?

                            Out of interest how many users is the application supposed to be serving?
                            the company is small by the moment 2, in one month maybe 3 more

                            for the other project about of more of 1000 - 10000 users we are thinking about which should be the best architecture

                            regards Karl

                            Comment


                            • #15
                              Originally posted by dr_pompeii View Post
                              i dont understand your expression, is not true that more ram can help the performance of the pc?
                              Yes sorry I've confused the situation. What I was saying was, it won't hurt performance e.g. it won't make it any worse, it should make it better.

                              Comment

                              Working...
                              X