|
16 | 16 |
|
17 | 17 | package org.springframework.boot.jdbc;
|
18 | 18 |
|
| 19 | +import java.beans.PropertyVetoException; |
19 | 20 | import java.lang.reflect.Method;
|
20 | 21 | import java.sql.SQLException;
|
21 | 22 | import java.util.Collections;
|
|
27 | 28 |
|
28 | 29 | import javax.sql.DataSource;
|
29 | 30 |
|
| 31 | +import com.mchange.v2.c3p0.ComboPooledDataSource; |
30 | 32 | import com.zaxxer.hikari.HikariDataSource;
|
31 | 33 | import oracle.jdbc.datasource.OracleDataSource;
|
32 | 34 | import oracle.ucp.jdbc.PoolDataSource;
|
@@ -391,6 +393,8 @@ private static <T extends DataSource> MappedDataSourceProperties<T> lookupPooled
|
391 | 393 | MappedDbcp2DataSource::new);
|
392 | 394 | result = lookup(classLoader, type, result, "oracle.ucp.jdbc.PoolDataSourceImpl",
|
393 | 395 | OraclePoolDataSourceProperties::new, "oracle.jdbc.OracleConnection");
|
| 396 | + result = lookup(classLoader, type, result, "com.mchange.v2.c3p0.ComboPooledDataSource", |
| 397 | + ComboPooledDataSourceProperties::new); |
394 | 398 | return result;
|
395 | 399 | }
|
396 | 400 |
|
@@ -650,6 +654,29 @@ public Class<? extends PoolDataSource> getDataSourceInstanceType() {
|
650 | 654 |
|
651 | 655 | }
|
652 | 656 |
|
| 657 | + /** |
| 658 | + * {@link DataSourceProperties} for C3P0. |
| 659 | + */ |
| 660 | + private static class ComboPooledDataSourceProperties extends MappedDataSourceProperties<ComboPooledDataSource> { |
| 661 | + |
| 662 | + ComboPooledDataSourceProperties() { |
| 663 | + add(DataSourceProperty.URL, ComboPooledDataSource::getJdbcUrl, ComboPooledDataSource::setJdbcUrl); |
| 664 | + add(DataSourceProperty.DRIVER_CLASS_NAME, ComboPooledDataSource::getDriverClass, this::setDriverClass); |
| 665 | + add(DataSourceProperty.USERNAME, ComboPooledDataSource::getUser, ComboPooledDataSource::setUser); |
| 666 | + add(DataSourceProperty.PASSWORD, ComboPooledDataSource::getPassword, ComboPooledDataSource::setPassword); |
| 667 | + } |
| 668 | + |
| 669 | + private void setDriverClass(ComboPooledDataSource dataSource, String driverClass) { |
| 670 | + try { |
| 671 | + dataSource.setDriverClass(driverClass); |
| 672 | + } |
| 673 | + catch (PropertyVetoException ex) { |
| 674 | + throw new IllegalArgumentException(ex); |
| 675 | + } |
| 676 | + } |
| 677 | + |
| 678 | + } |
| 679 | + |
653 | 680 | /**
|
654 | 681 | * {@link DataSourceProperties} for Spring's {@link SimpleDriverDataSource}.
|
655 | 682 | */
|
|
0 commit comments