MySQL 服务器的连接池?
我找到了很多关于如何使用 JNDI 创建 MySQL 服务器连接池的资源;但是,我想知道如果我只想使用独立的Java类来连接MySQL服务器并使用连接池机制(无需应用程序服务器的帮助),我该如何解决?
I find many resources about how to create the connection pool with JNDI to the MySQL Server; however, I want to know if I just want to use a standalone Java class to connect the MySQL Server and with a connection pool mechanism (without the help of app server), how could I figure it out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Tomcat 的连接池是一个名为 DBCP 的独立组件。您可以下载它并在没有 Tomcat 的情况下使用它:
http://commons.apache.org/dbcp/
另一个非常流行的连接池是 C3P0(我相信 Hibernate 内部使用它)。可以在这里下载:
http://sourceforge.net/projects/c3p0/
Tomcat's connection pool is a separate component named DBCP. You can download it and use it without Tomcat:
http://commons.apache.org/dbcp/
Another very popular connection pool is C3P0 (which I believe is used by Hibernate internally). It can be downloaded here:
http://sourceforge.net/projects/c3p0/
如果您没有使用应用程序服务器来处理连接池,另一种选择是自己实现一个,您必须注意哪个连接已死亡并重新初始化,根据请求分发免费连接等...这里阅读起来有点简单: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html
另一种方法是查找连接池 java 包,例如这个: http://www.snaq.net/java/DBPool/,这是我在谷歌搜索中找到的第一个包,所以我没有知道好不好,举个例子。
If you are not using an app server to handle your connection pool, the other option are implement one yourself, where you have to pay attention to which connection is dead and re-init, hands out free connections upon request, etc... Here is a little light reading on it: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html
Other way is look for connection pool java packages such as this one: http://www.snaq.net/java/DBPool/, this is the first package I found googling, so I have no idea if it is good or not, just an example.