Mention HikariCP next to DBCP and C3P0 in connection pool notes

Closes gh-24405
This commit is contained in:
Juergen Hoeller 2020-01-24 14:54:02 +01:00
parent d085577e0a
commit 60c7af3625
4 changed files with 35 additions and 33 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,12 +52,13 @@ import org.springframework.util.ClassUtils;
* {@link org.springframework.mock.jndi.SimpleNamingContextBuilder}, or switch the * {@link org.springframework.mock.jndi.SimpleNamingContextBuilder}, or switch the
* bean definition to a local DataSource (which is simpler and thus recommended). * bean definition to a local DataSource (which is simpler and thus recommended).
* *
* <p>If you need a "real" connection pool outside of a Java EE container, consider * <p>This {@code DriverManagerDataSource} class was originally designed alongside
* <a href="https://commons.apache.org/proper/commons-dbcp">Apache Commons DBCP</a> * <a href="https://commons.apache.org/proper/commons-dbcp">Apache Commons DBCP</a>
* or <a href="https://sourceforge.net/projects/c3p0">C3P0</a>. * and <a href="https://sourceforge.net/projects/c3p0">C3P0</a>, featuring bean-style
* Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full * {@code BasicDataSource}/{@code ComboPooledDataSource} classes with configuration
* connection pool beans, supporting the same basic properties as this class * properties for local resource setups. For a modern JDBC connection pool, consider
* plus specific settings (such as minimal/maximal pool size etc). * <a href="https://github.com/brettwooldridge/HikariCP">HikariCP</a> instead,
* exposing a corresponding {@code HikariDataSource} instance to the application.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 14.03.2003 * @since 14.03.2003

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -40,12 +40,13 @@ import org.springframework.util.Assert;
* ApplicationContext via {@link org.springframework.jndi.JndiObjectFactoryBean}, * ApplicationContext via {@link org.springframework.jndi.JndiObjectFactoryBean},
* for seamless switching to and from a local DataSource bean like this class. * for seamless switching to and from a local DataSource bean like this class.
* *
* <p>If you need a "real" connection pool outside of a Java EE container, consider * <p>This {@code SimpleDriverDataSource} class was originally designed alongside
* <a href="https://commons.apache.org/proper/commons-dbcp">Apache Commons DBCP</a> * <a href="https://commons.apache.org/proper/commons-dbcp">Apache Commons DBCP</a>
* or <a href="https://sourceforge.net/projects/c3p0">C3P0</a>. * and <a href="https://sourceforge.net/projects/c3p0">C3P0</a>, featuring bean-style
* Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full * {@code BasicDataSource}/{@code ComboPooledDataSource} classes with configuration
* connection pool beans, supporting the same basic properties as this class * properties for local resource setups. For a modern JDBC connection pool, consider
* plus specific settings (such as minimal/maximal pool size etc). * <a href="https://github.com/brettwooldridge/HikariCP">HikariCP</a> instead,
* exposing a corresponding {@code HikariDataSource} instance to the application.
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.5.5 * @since 2.5.5

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,13 +20,13 @@ import javax.sql.DataSource;
/** /**
* {@code DataSourceFactory} encapsulates the creation of a particular * {@code DataSourceFactory} encapsulates the creation of a particular
* {@link DataSource} implementation such as a * {@link DataSource} implementation such as a non-pooling
* {@link org.springframework.jdbc.datasource.SimpleDriverDataSource * {@link org.springframework.jdbc.datasource.SimpleDriverDataSource}
* SimpleDriverDataSource} or a connection pool such as Apache DBCP or C3P0. * or a HikariCP pool setup in the shape of a {@code HikariDataSource}.
* *
* <p>Call {@link #getConnectionProperties()} to configure normalized * <p>Call {@link #getConnectionProperties()} to configure normalized
* {@code DataSource} properties before calling {@link #getDataSource()} to * {@code DataSource} properties before calling {@link #getDataSource()}
* actually get the configured {@code DataSource} instance. * to actually get the configured {@code DataSource} instance.
* *
* @author Keith Donald * @author Keith Donald
* @author Sam Brannen * @author Sam Brannen
@ -35,14 +35,14 @@ import javax.sql.DataSource;
public interface DataSourceFactory { public interface DataSourceFactory {
/** /**
* Get the {@linkplain ConnectionProperties connection properties} of the * Get the {@linkplain ConnectionProperties connection properties}
* {@link #getDataSource DataSource} to be configured. * of the {@link #getDataSource DataSource} to be configured.
*/ */
ConnectionProperties getConnectionProperties(); ConnectionProperties getConnectionProperties();
/** /**
* Get the {@link DataSource} with the {@linkplain #getConnectionProperties * Get the {@link DataSource} with the
* connection properties} applied. * {@linkplain #getConnectionProperties connection properties} applied.
*/ */
DataSource getDataSource(); DataSource getDataSource();

View File

@ -3613,20 +3613,20 @@ part of the JDBC specification and is a generalized connection factory. It lets
container or a framework hide connection pooling and transaction management issues container or a framework hide connection pooling and transaction management issues
from the application code. As a developer, you need not know details about how to from the application code. As a developer, you need not know details about how to
connect to the database. That is the responsibility of the administrator who sets up connect to the database. That is the responsibility of the administrator who sets up
the datasource. You most likely fill both roles as you develop and test code, but you do the datasource. You most likely fill both roles as you develop and test code, but you
not necessarily have to know how the production data source is configured. do not necessarily have to know how the production data source is configured.
When you use Spring's JDBC layer, you can obtain a data source from JNDI, or you can configure your When you use Spring's JDBC layer, you can obtain a data source from JNDI, or you can
own with a connection pool implementation provided by a third party. Popular configure your own with a connection pool implementation provided by a third party.
implementations are Apache Jakarta Commons DBCP and C3P0. Implementations in the Spring Traditional choices are Apache Commons DBCP and C3P0 with bean-style `DataSource` classes;
distribution are meant only for testing purposes and do not provide pooling. for a modern JDBC connection pool, consider HikariCP with its builder-style API instead.
This section uses Spring's `DriverManagerDataSource` implementation, and several NOTE: You should use the `DriverManagerDataSource` and `SimpleDriverDataSource` classes
additional implementations are covered later. (as included in the Spring distribution) only for testing purposes! Those variants do not
provide pooling and perform poorly when multiple requests for a connection are made.
NOTE: You should use the `DriverManagerDataSource` class only for testing purposes, The following section uses Spring's `DriverManagerDataSource` implementation.
since it does not provide pooling and performs poorly when multiple requests for a Several other `DataSource` variants are covered later.
connection are made.
To configure a `DriverManagerDataSource`: To configure a `DriverManagerDataSource`: