简体   繁体   English

启用连接池Spring ibatis

[英]Enable connection pooling Spring ibatis

I am using spring Ibatis for database management in my java application.I need to enable connection pooling to increase the performance of the application. 我正在使用Spring Ibatis在Java应用程序中进行数据库管理。我需要启用连接池以提高应用程序的性能。

i added following properties to SqlMapConfig.xml file to enable the connection pooling 我向SqlMapConfig.xml文件添加了以下属性以启用连接池

  <transactionManager type="JDBC" commitRequired="false">
    <dataSource type="SIMPLE">
      <property name="JDBC.Driver" value="com.mysql.jdbc.Driver"/>
      <property name="JDBC.ConnectionURL" value="jdbc:mysql://localhost:3306/xxxxx"/>
      <property name="JDBC.Username" value="xxxxxx"/>
      <property name="JDBC.Password" value="xxxxxxx"/>
      <property name="Pool.MaximumActiveConnections" value="50"/>
      <property name="Pool.MaximumIdleConnections" value="20"/>

    </dataSource>
  </transactionManager>

But i couldn't find any visible performance changes.Do i need to make any other changes or settings changes to enable the connection pooling?. 但是我找不到任何可见的性能更改。是否需要进行任何其他更改或设置更改才能启用连接池?

Following JAR files are added in my build path 在我的构建路径中添加了以下JAR文件

ibatis-2.3.4.726.jar ibatis2-common-2.1.6.589.jar ibatis2-dao-2.1.6.589.jar ibatis-2.3.4.726.jar ibatis2-common-2.1.6.589.jar ibatis2-dao-2.1.6.589.jar

I also noted that you cannot set a minimum set of connections during startup. 我还指出,您无法在启动过程中设置最少的连接集。 So 50 simultaneous requests at start of your test will all try to setup a database connection. 因此,在测试开始时有50个同时请求都将尝试建立数据库连接。 Just as in the single connection case. 就像在单连接情况下一样。 Try using a real connection pool implementation with a DataSource. 尝试将实际的连接池实现与数据源一起使用。 Or make sure you are testing your performance after pool has been filled. 或者确保在池已满后测试性能。

Try using a real pool implementation. 尝试使用真实的池实现。 JDBC pool is quite popular and avoids some of the locking issues older pooling implementations have. JDBC池非常流行,它避免了较早的池实现所具有的一些锁定问题。 See http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html . 参见http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html

Also measure your performance and make sure you really are using connection pooling. 还要衡量您的性能,并确保您确实在使用连接池。 I have seen sharing of one connection over a whole application which also could explain what you are experiencing. 我已经看到在整个应用程序中共享一个连接,这也可以解释您遇到的情况。

尝试使用dataSource类型的POOLED而不是SIMPLE。

<dataSource type="POOLED">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM