Skip to content

Add support for unpooled JDBC datasources#1780

Open
rrobetti wants to merge 16 commits intomicronaut-projects:7.0.xfrom
rrobetti:7.0.x
Open

Add support for unpooled JDBC datasources#1780
rrobetti wants to merge 16 commits intomicronaut-projects:7.0.xfrom
rrobetti:7.0.x

Conversation

@rrobetti
Copy link
Copy Markdown

Implements Issue: #1779

Copilot AI and others added 9 commits December 10, 2025 16:21
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
- Add new jdbc-unpooled module to settings.gradle
- Create UnpooledDataSource: simple DataSource using DriverManager
- Create DatasourceConfiguration: configuration bean with calculated settings
- Create DatasourceFactory: factory for creating unpooled datasources
- Add comprehensive tests for unpooled connections
- Add JSpecify dependency to jdbc and jdbc-unpooled modules
- All tests pass (10/10)
- Checkstyle and Spotless pass

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
- Create jdbc-unpooled.adoc with full documentation
- Update toc.yml to include unpooled datasource section
- Update jdbc.adoc to mention unpooled option
- Update jdbc-connection-pools.adoc table to include unpooled
- Documentation covers installation, configuration, use cases, performance considerations
- Includes examples for migration between pooled and unpooled
- Comprehensive warnings about performance implications

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
- Add database proxy (CNAM, pgpool, Open J Proxy) as first use case in package-info.java
- Update warning text to mention externalized connection pooling
- Remove production and microservices restrictions (valid with proxies)
- Add note about performance considerations not applying with database proxies
- Update jdbc.adoc warning to include database proxy use case
- Delete ANALYSIS_README.md and IMPLEMENTATION_CHECKLIST.md files

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Remove analysis document as requested - no longer needed in the PR.

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…ction-pool

Implement jdbc-unpooled module for unpooled database connections in Micronaut SQL
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Dec 11, 2025

CLA assistant check
All committers have signed the CLA.

@EachBean(DatasourceConfiguration.class)
@Requires(condition = JdbcDataSourceEnabled.class)
public DataSource dataSource(DatasourceConfiguration datasourceConfiguration) {
UnpooledDataSource ds = new UnpooledDataSource(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a delegating UnpooledDataSource? You should simply create a DataSource that is specified (maybe also add some builder option)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rationale for implementing unpolled datasource support is documented here #1779.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand, please describe the reason

@dstepanov
Copy link
Copy Markdown
Contributor

Please sign CLA

@dstepanov
Copy link
Copy Markdown
Contributor

Maybe we can implement it without an extra dependency, simply by enable it with some property WDYT @radovanradic

@radovanradic
Copy link
Copy Markdown
Contributor

Maybe we can implement it without an extra dependency, simply by enable it with some property WDYT @radovanradic

Maybe adding DatasourceFactory in jdbc module that will also have @EachBean(BasicJdbcConfiguration.class) but with condition that BasicJdbcConfiguration.disable-pool=true ?

@rrobetti
Copy link
Copy Markdown
Author

Maybe we can implement it without an extra dependency, simply by enable it with some property WDYT @radovanradic

Maybe adding DatasourceFactory in jdbc module that will also have @EachBean(BasicJdbcConfiguration.class) but with condition that BasicJdbcConfiguration.disable-pool=true ?

thanks for your comment, how would that look like? Can you provide more info? Should I change this implementation?

@radovanradic
Copy link
Copy Markdown
Contributor

radovanradic commented Dec 12, 2025

Maybe we can implement it without an extra dependency, simply by enable it with some property WDYT @radovanradic

Maybe adding DatasourceFactory in jdbc module that will also have @EachBean(BasicJdbcConfiguration.class) but with condition that BasicJdbcConfiguration.disable-pool=true ?

thanks for your comment, how would that look like? Can you provide more info? Should I change this implementation?

I think what Denis suggested is there is no need for new module for this. Maybe you can just have UnpooledDatasourceFactory in jdbc module and then just create DataSource or as you named it UnpooledDataSource. And maybe there should be flag to tell whether datasource will be pooled to activate that factory, using condition similar to io.micronaut.jdbc.JdbcDataSourceEnabled but Denis might clarify more what he suggested.
Btw, this looks nice and simple to me.

@rrobetti
Copy link
Copy Markdown
Author

Maybe we can implement it without an extra dependency, simply by enable it with some property WDYT @radovanradic

Maybe adding DatasourceFactory in jdbc module that will also have @EachBean(BasicJdbcConfiguration.class) but with condition that BasicJdbcConfiguration.disable-pool=true ?

thanks for your comment, how would that look like? Can you provide more info? Should I change this implementation?

I think what Denis suggested is there is no need for new module for this. Maybe you can just have UnpooledDatasourceFactory in jdbc module and then just create DataSource or as you named it UnpooledDataSource. And maybe there should be flag to tell whether datasource will be pooled to activate that factory, using condition similar to io.micronaut.jdbc.JdbcDataSourceEnabled but Denis might clarify more what he suggested.

@dstepanov can you add your take on this?

@dstepanov
Copy link
Copy Markdown
Contributor

I don’t think we need a new module, maybe just an option like “allow-not-pulling-datasource=true” globally or per datasouce

Copilot AI and others added 7 commits December 22, 2025 20:12
…rceConfiguration to jdbc module

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…ed flag

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…proach

Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
Co-authored-by: rrobetti <7221783+rrobetti@users.noreply.github.com>
…urce

Move unpooled datasource implementation to jdbc module with configuration flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants