Comments (5)
From @eepstein
Here’s part of a Java 1.5 Generics way to support other DataSources and also the release() functionality:
public final class YankPoolManager<T extends DataSource & Closeable> {
…
private final Map<String, T> pools = ...
...
protected void addDataSource(String name, T ds) {
pools.put(name, ds);
}
and then, inside #release() call close() inside a try block.
from yank.
Of the following connection pools, only Hikari and BoneCP implement Closeable
.
JDBC Connection Pool | Implements | methods |
---|---|---|
Hikari | DataSource, Closeable | close(),shutdown() |
BoneCP | DataSource, Closeable | close(),shutdown() |
C3P0 | DataSource | close() |
DBCP | DataSource | close() |
ViburCP | DataSource | terminate() |
It's lame that DataSource
doesn't have a close()
method.
from yank.
2 out of 5 . .. not bad ;-)
Bummer is that 4 of the 5 implement close() but don’t declare the interface. Fall-back would be dynamic dispatch via something like javassist with introspection, which is what Hikari does for calls to the underlying DataSource… but seems like a hassle. The nice thing about doing the generic is it leaves the door open to anyone who wants to write such a wrapper / delegation - whether implemented via dynamic dispatch or long-hand. And it makes the coupling to the CP looser.
But still, less coverage than getting all 5 of those, which would be ideal.
On Feb 14, 2015, at 4:34 PM, Tim Molter [email protected] wrote:
Of the following connection pools, only Hikari and BoneCP implement Closeable.
| JDBC Connection Pool | Implements | methods |
|---|---|
|Hikari|DataSource, Closeable|close(),shutdown()|
|BoneCP|DataSource, Closeable|close(),shutdown()|
|C3P0|DataSource|close()|
|DBCP|DataSource|close()|
|ViburCP|DataSource|terminate()|—
Reply to this email directly or view it on GitHub #21 (comment).
from yank.
hmm. The Java-8 approach I’d take would be to include an optional “closer” Function in the addConnectionPool() method. Default (null) would cast to closable and call close(), but if caller provided a closer function the release method would invoke that. This is fully general then, but with lambda’s required an Interface and someone to implement for each CP type they want to use. That said, the Interface in this case has 1 method, so unlike wrapping and delegating this is lightweight and goes general purpose…. Works , but is clearly a work-around. That said, if you think that fits, then it’s light-weight on the coding side. So, if yes, lemme know if you want me to code that.
On Feb 14, 2015, at 4:34 PM, Tim Molter [email protected] wrote:
Of the following connection pools, only Hikari and BoneCP implement Closeable.
| JDBC Connection Pool | Implements | methods |
|---|---|
|Hikari|DataSource, Closeable|close(),shutdown()|
|BoneCP|DataSource, Closeable|close(),shutdown()|
|C3P0|DataSource|close()|
|DBCP|DataSource|close()|
|ViburCP|DataSource|terminate()|—
Reply to this email directly or view it on GitHub #21 (comment).
from yank.
Nah, using the default Hikari is simple and effective for the purpose of this lib.
from yank.
Related Issues (20)
- is compatible with r2dbc? HOT 1
- ClassNotFoundException: org.knowm.yank.Yank
- Cannot use insert or insertBatch with SQLite
- MS VSCode SpringBoot HOT 1
- Allow adding a pre-configured HikariDataSource HOT 1
- Replace InsertedIDResultSetHandler with (built-in) ScalarHandler HOT 5
- Add check to make sure there is a default constructor HOT 1
- queryColumnSQLKey is not working as intended HOT 9
- Connection Pooling issue HOT 35
- hikari 2.4.1, compatibility Patch shutdown() to close() HOT 9
- where is the poolname in the new version? HOT 4
- concurrent, multiuser and custom database HOT 2
- how do you get the sql exceptions ? HOT 2
- Include p6spy for better logging HOT 1
- I can't find release 3.3.0 in any maven repo HOT 1
- MariaDB 10.0 HOT 1
- Update dependencies? HOT 1
- Update dependency dbutils to 1.8 HOT 2
- set variables HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yank.