Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL implementation of connection pools

Tags:

java

mysql

jdbc

Does MySQL jdbc driver has built in support for database connection pools? (like Oracle has OracleDataSource class)

I did a thorough search but couldn't find any. I know that I can use external libraries such as dbcp or boneCp and also that application servers such as tomcat and jboss supports connection pools.

But I would be interested to know if MySQL does have it's own implementation of connection pools.

Thank in advance.

like image 761
Sach Avatar asked Dec 12 '14 12:12

Sach


1 Answers

The JDBC specification (see in particular page 68) supports connection pooling, so any modern driver has that capability. However, the intention isn't for JDBC drivers to maintain their own connection pools; so whether you're using MySQL Connector/J or Oracle driver, you still need the connection pool implementation provided by an application server or a third party library.

Unless of course you want to try rolling your own. o.O

The relevant JDBC interfaces are javax.sql.ConnectionPoolDataSource and javax.sql.PooledConnection.

In the latest MySql driver, the corresponding implementation classes are MysqlConnectionPoolDataSource and MysqlPooledConnection (both in package com.mysql.jdbc.jdbc2.optional). You may find these code examples interesting - they're using a class called MiniConnectionPoolManager as the connection pool implementation.

like image 78
gknicker Avatar answered Oct 03 '22 17:10

gknicker