Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
*
* <pre>{@code
*
* DataSourceConfig config = new DataSourceConfig();
* config.setUrl("jdbc:h2:mem:tests2");
* config.setUsername("sa");
* config.setPassword("");
*
* DataSourcePool pool = DataSourceFactory.create("test", config);
* DataSourcePool pool = DataSourcePool.builder()
* .name("test")
* .url("jdbc:h2:mem:tests2")
* .username("sa")
* .password("")
* .build();
*
* Connection connection = pool.getConnection();
*
Expand All @@ -20,7 +20,20 @@ public interface DataSourceFactory {

/**
* Create the DataSourcePool given the name and configuration.
*
* @deprecated Migrate to {@link DataSourcePool#builder()} and {@link DataSourceBuilder#build()}.
* <pre>{@code
*
* DataSourcePool pool = DataSourcePool.builder()
* .name("test")
* .url("jdbc:h2:mem:tests2")
* .username("sa")
* .password("")
* .build();
*
* }</pre>
*/
@Deprecated
static DataSourcePool create(String name, DataSourceConfig config) {
config.defaultConnectionInitializer(DSManager.defaultInitializer());
return DSManager.get().createPool(name, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
class DataSourcePoolFactoryTest {

@Test
@SuppressWarnings("deprecation") // intentionally covers the deprecated DataSourceFactory.create()
void createPool() throws Exception {

DataSourceConfig config = new DataSourceConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.ebean.datasource.DataSourceBuilder;
import io.ebean.datasource.DataSourceConfig;
import io.ebean.datasource.DataSourceFactory;
import io.ebean.datasource.DataSourcePool;
import io.ebean.test.containers.PostgresContainer;
import org.junit.jupiter.api.AfterAll;
Expand Down Expand Up @@ -86,7 +85,7 @@ void test_with_applicationNameAndSchema() throws SQLException {
ds.setPassword("test");
ds.setApplicationName("my-application-name");

DataSourcePool pool = DataSourceFactory.create("app", ds);
DataSourcePool pool = ds.name("app").build();
try {
try (Connection connection = pool.getConnection()) {
setupTable(connection, "my_table");
Expand Down Expand Up @@ -117,7 +116,7 @@ void test_password2() throws SQLException {
ds.setPassword("test");
ds.setPassword2("newRolledPassword");

DataSourcePool pool = DataSourceFactory.create("app", ds);
DataSourcePool pool = ds.name("app").build();
try {
try (Connection connection0 = pool.getConnection()) {
setupTable(connection0, "my_table2");
Expand Down Expand Up @@ -147,7 +146,7 @@ void test_password2() throws SQLException {
}

// a new pool switches immediately
DataSourcePool pool2 = DataSourceFactory.create("app2", ds);
DataSourcePool pool2 = ds.name("app2").build();
try (var connP2_0 = pool2.getConnection()) {
testConnectionWithSelect(connP2_0, "select acol from app.my_table2");
try (var connP2_1 = pool2.getConnection()) {
Expand Down
Loading