diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle
index 0e6470c774..5c12025ae7 100644
--- a/spring-boot-project/spring-boot-dependencies/build.gradle
+++ b/spring-boot-project/spring-boot-dependencies/build.gradle
@@ -2484,6 +2484,14 @@ bom {
releaseNotes("https://github.com/mojohaus/versions/releases/tag/{version}")
}
}
+ library("Vibur", "25.0") {
+ group("org.vibur") {
+ modules = [
+ "vibur-dbcp",
+ "vibur-object-pool"
+ ]
+ }
+ }
library("WebJars Locator Lite", "1.0.1") {
group("org.webjars") {
modules = [
diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc
index 5fb6925120..4a1615f10f 100644
--- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc
+++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/data/sql.adoc
@@ -142,6 +142,7 @@ The following connection pools are supported by javadoc:org.springframework.boot
* H2 javadoc:org.h2.jdbcx.JdbcDataSource[]
* PostgreSQL javadoc:org.postgresql.ds.PGSimpleDataSource[]
* C3P0
+* Vibur
diff --git a/spring-boot-project/spring-boot/build.gradle b/spring-boot-project/spring-boot/build.gradle
index 6d8fac07ed..732a56e592 100644
--- a/spring-boot-project/spring-boot/build.gradle
+++ b/spring-boot-project/spring-boot/build.gradle
@@ -96,6 +96,7 @@ dependencies {
exclude group: "org.eclipse.jetty", module: "jetty-servlet"
exclude group: "jakarta.mail", module: "jakarta.mail-api"
}
+ optional("org.vibur:vibur-dbcp")
optional("org.yaml:snakeyaml")
optional("org.jetbrains.kotlin:kotlin-reflect")
optional("org.jetbrains.kotlin:kotlin-stdlib")
diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java
index 8281e06e06..6a37eae673 100644
--- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java
+++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java
@@ -36,6 +36,7 @@ import oracle.ucp.jdbc.PoolDataSourceImpl;
import org.apache.commons.dbcp2.BasicDataSource;
import org.h2.jdbcx.JdbcDataSource;
import org.postgresql.ds.PGSimpleDataSource;
+import org.vibur.dbcp.ViburDBCPDataSource;
import org.springframework.beans.BeanUtils;
import org.springframework.core.ResolvableType;
@@ -60,6 +61,7 @@ import org.springframework.util.StringUtils;
*
Apache DBCP2 ({@code org.apache.commons.dbcp2.BasicDataSource})
* Oracle UCP ({@code oracle.ucp.jdbc.PoolDataSourceImpl})
* C3P0 ({@code com.mchange.v2.c3p0.ComboPooledDataSource})
+ * Vibur {@code org.vibur.dbcp.ViburDBCPDataSource}
*
*
* The following non-pooling {@link DataSource} implementations can be used when
@@ -412,6 +414,8 @@ public final class DataSourceBuilder {
OraclePoolDataSourceProperties::new, "oracle.jdbc.OracleConnection");
result = lookup(classLoader, type, result, "com.mchange.v2.c3p0.ComboPooledDataSource",
ComboPooledDataSourceProperties::new);
+ result = lookup(classLoader, type, result, "org.vibur.dbcp.ViburDBCPDataSource",
+ ViburDataSourceProperties::new);
return result;
}
@@ -694,6 +698,18 @@ public final class DataSourceBuilder {
}
+ private static class ViburDataSourceProperties extends MappedDataSourceProperties {
+
+ ViburDataSourceProperties() {
+ add(DataSourceProperty.URL, ViburDBCPDataSource::getJdbcUrl, ViburDBCPDataSource::setJdbcUrl);
+ add(DataSourceProperty.DRIVER_CLASS_NAME, ViburDBCPDataSource::getDriverClassName,
+ ViburDBCPDataSource::setDriverClassName);
+ add(DataSourceProperty.USERNAME, ViburDBCPDataSource::getUsername, ViburDBCPDataSource::setUsername);
+ add(DataSourceProperty.PASSWORD, ViburDBCPDataSource::getPassword, ViburDBCPDataSource::setPassword);
+ }
+
+ }
+
/**
* {@link DataSourceProperties} for Spring's {@link SimpleDriverDataSource}.
*/
diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilderRuntimeHints.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilderRuntimeHints.java
index a91efdf7b2..ae306c7303 100644
--- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilderRuntimeHints.java
+++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilderRuntimeHints.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2023 the original author or authors.
+ * Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,6 +43,7 @@ class DataSourceBuilderRuntimeHints implements RuntimeHintsRegistrar {
typeNames.add("org.apache.commons.dbcp2.BasicDataSource");
typeNames.add("oracle.jdbc.datasource.OracleDataSource");
typeNames.add("oracle.ucp.jdbc.PoolDataSource");
+ typeNames.add("org.vibur.dbcp.ViburDBCPDataSource");
typeNames.add("org.postgresql.ds.PGSimpleDataSource");
typeNames.add("org.springframework.jdbc.datasource.SimpleDriverDataSource");
typeNames.add("org.apache.tomcat.jdbc.pool.DataSource");
diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderRuntimeHintsTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderRuntimeHintsTests.java
index 3332d07326..df82f638b7 100644
--- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderRuntimeHintsTests.java
+++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderRuntimeHintsTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2023 the original author or authors.
+ * Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ class DataSourceBuilderRuntimeHintsTests {
.of(com.mchange.v2.c3p0.ComboPooledDataSource.class, org.h2.jdbcx.JdbcDataSource.class,
com.zaxxer.hikari.HikariDataSource.class, org.apache.commons.dbcp2.BasicDataSource.class,
oracle.jdbc.datasource.OracleDataSource.class, oracle.ucp.jdbc.PoolDataSource.class,
- org.postgresql.ds.PGSimpleDataSource.class,
+ org.vibur.dbcp.ViburDBCPDataSource.class, org.postgresql.ds.PGSimpleDataSource.class,
org.springframework.jdbc.datasource.SimpleDriverDataSource.class,
org.apache.tomcat.jdbc.pool.DataSource.class)
.forEach((dataSourceType) -> {
diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderTests.java
index 87778a9e5a..f8c1a62662 100644
--- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderTests.java
+++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceBuilderTests.java
@@ -42,6 +42,7 @@ import org.h2.jdbcx.JdbcDataSource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.postgresql.ds.PGSimpleDataSource;
+import org.vibur.dbcp.ViburDBCPDataSource;
import org.springframework.jdbc.datasource.AbstractDataSource;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
@@ -504,6 +505,23 @@ class DataSourceBuilderTests {
assertThat(c3p0DataSource.getDriverClass()).isEqualTo("com.example.Driver");
}
+ @Test // gh-42903
+ void buildWhenViburTypeSpecifiedReturnsExpectedDataSource() {
+ this.dataSource = DataSourceBuilder.create()
+ .url("jdbc:postgresql://localhost:5432/postgres")
+ .type(ViburDBCPDataSource.class)
+ .username("test")
+ .password("secret")
+ .driverClassName("com.example.Driver")
+ .build();
+ assertThat(this.dataSource).isInstanceOf(ViburDBCPDataSource.class);
+ ViburDBCPDataSource viburDataSource = (ViburDBCPDataSource) this.dataSource;
+ assertThat(viburDataSource.getJdbcUrl()).isEqualTo("jdbc:postgresql://localhost:5432/postgres");
+ assertThat(viburDataSource.getUsername()).isEqualTo("test");
+ assertThat(viburDataSource.getPassword()).isEqualTo("secret");
+ assertThat(viburDataSource.getDriverClassName()).isEqualTo("com.example.Driver");
+ }
+
private DataSource wrap(DataSource target) {
return new DataSourceWrapper(target);
}