Which JDBC connection pool library should I use for a new application project (not web application)?
Apache DBCP has enough unresolved issues which are pushed until 2.0 I think.
C3P0 development seems to be stopped.
And both of them looks relatively slow.
Proxool is dead.
DBPool has almost no community (at least I've found no public one - no forums, no mailing lists...)
Apache Tomcat Pool looks to be unusable without Tomcat
I've found SQL Datasources article at Oracle website, but it seems, that it can be applied only to applets running in containers like servlets and web services.
Should I choose BoneCP may be? I don't have any huge requirements. I just need a good and easy to use database connection pool, that is in active development. Library, whose author can respond to bug reports, answer some specific question etc.
BTW, actually, I'm using MySQL only. I've found, that MySQL driver supports DriverManager interface, but I'm unsure if it actually pools connections or not.
You've done good research. I'd say, go ahead with BoneCP. Some years ago I would have suggested c3p0, but it has currently some open and unresolved issues as well. Too bad, actually. The BoneCP author is by the way also active here at SO.
It is possible use Tomcat Connection Pool without Tomcat, it is just a couple of .jars that you can include to any software. I have successfully used Tomcat Connection Pool with Resin and Jetty application servers.
Another alternative is Vibur DBCP. This is a new, concurrent JDBC connection pool based on Java dynamic proxies. It is fast, has concise source code, supports fairness parameter, JDBC Statement caching, long running SQL queries logging, and many other features.
Vibur DBCP is available in the central Maven repo, the website shows the needed Maven dependency, various configuration examples (with Spring, Hibernate 3.x/4.x/5.x), and all configuration options.
Vibur DBCP requires Java 1.7.
Disclaimer: I'm the author of Vibur DBCP.
I know its too late for answer but I just found an interesting link which has given a broader scope to answer most your queries. But at the end HikariCP and BoneCP are much better than other options.
Related
I am pretty sure WebLogic, Websphere, Jboss EAP and other J2EE application server provides their own service to optimize database connection pooling. At this point is there any benefit to still integrate a Spring application with HikariCp? May be HikariCp performs better (in question) but there will be unavoidable issues for configuration and compatibility.
Better question is: what are the benefits to use HikariCp in a Spring application if it will deploy on major commercial application servers other than Tomcat etc..
There is an opinion that HikariCp is the fastest connection pool in java world, this graphics prove this fact. In this case criteria is statement Cycle in ops/ms. HikariCp is faster in two times than the closest rival. It's a source code of this benchmarks, if i were you, i would launch them on own PC with specific to my environment. Last link saves your time, you have already written benchmarks (it's benefits of open source). HTH
What are the tools and approaches you suggest to use for monitoring performance? My app is running on Tomcat, Spring 3, JPA, Hibernate and solr. I've noticed some lag/slow activity on a certain page.
The app does not have any code of cache setup. Or even connection pooling.
Pardon my beginner-style questions, I'm only entering the "performance monitoring" world just now...
I know couple of things to look at is- dabatase calls, connection pooling, indexed tables, caching etc.
You absolutely need connection pooling. It's a no-brainer, there are libraries like Bone CP, Commons DBCP or c3p0 that do this transparently.
You must implemented automated load/stress test. JMeter is pretty easy to use, other tools like that are Gatling and Grinder.
Enable SQL logging and statistics. Most likely too many or too complex queries are slowing down your page.
Use a profiler. Either commercial (JProfiler, YourKit) or the one included in JVisualVM.
You can use this application to monitor your application:
http://newrelic.com/
He has a free plan!
I am currently working on an enterprise application that is deployed to GlassFish. I am attempting to figure out the right way to communicate to a cassandra backend from within an EJB that has been deployed to GlassFish 3.1. I would prefere to use Pelops to talk to Cassandra.
Disclaimer: I am new to Java EE and the concepts behind enterprise app servers and EJBs; one of the purposes of this project is to learn these topics. This is out of scope of this question as I am really just looking to be pointed in the right direction for best practices or where I should go to find best practices; so far google has not been very helpful/consistent on this topic.
More specifically, should I be thinking about writing a JCA connector for cassandra? Using a singleton EJB that talks to cassandra via Pelops? Just use pelops directly in my EJBs? (though I thought your not supposed to create socket connections in ejbs) Something else entirely?
The EJB spec prohibits EJBs from opening server sockets, but not sockets. However, it does also prohibit EJBs from creating threads. Does Pelops (or Hector) create threads to handle its pooling?
The letter of the law aside, since both those libraries do pooling, they definitely feel like something that belongs in the resource adapter layer to me. I would be nervous about EJBs, whose lifecycle is controlled by the container, and is potentially quite short, hanging on to a resource like a connection pool whose lifecycle is somewhat independent, and should be longer.
That said, most implementations of EJB are quite forgiving, so whether the use of Pelops/Hector directly from EJBs is architecturally right or not, it is very likely that it will work.
If i had all the time in the world, i would write a resource adapter wrapping one or the other of those libraries. However, that would be a considerable investment of resources in pursuit of a negligible practical return.
we are developing a similar application where I work now, even if we do not implement EJB, we deploy a backend to Glassfish 3.1 and internally we have created a small library that talks to Cassandra.
Right now the most used library for connecting and working with Cassandra is Hector:
https://github.com/rantav/hector
It is very actively developed. I have never seen it in use inside an EJB, but I used it and it is very solid. Do not how Pelops is developed though.
What we have developed here is a very custom application tailored to our needs, that is why we didn't use Hector in the first place.
As long as you use client sockets in EJB, you should be safe, the restriction on EJB is for server socket that should be handled by the app server. But if you have other needs, you should write your JCA.
i am trying to use c3p0 in my current Spring based application. I am no database pooling expert and was wondering if there is a more or less a good example of a c3p0 configuration (in applicationContext.xml) that can be used against a MySQL database?
The pool should detect database connection loss and retries.
c3o0 is dead, do not use it. Use jdbc-pool
Here's the docs, (scroll down to How to use) http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html
Here's a good article on why is this better http://www.tomcatexpert.com/blog/2010/03/12/explaining-jdbc-pool-high-concurrency-alternative-connection-pooling-module
You mean c3p0 or hibernate-c3p0?
Hibernate has taken development for C3P0 and it is very well alive.
It just published version 4.0.0 CR1, which will be out with Hibernate 4.
I'm reading about c3p0 and dbcp for handling jdbc connections and heard alot of problems and people saying dbcp is dead but c3p0 can't do jdbc4 and so on. But I don't know if these posts are out of date.
Now I hit on BoneCP which explains how broken connections are handled here. Connections are wrapped and BoneCP does some prechecking of exceptions before they get passed to the application. If something is wrong with the connection BoneCP removes it from the pool.
1.) Do all these pools have that kind of connection handling?
2.) This question gets asked over and over again, but I couldn't find any answer from 2011. What one shall I use for a new application, that will be maintained for the next 10 years, if not more.
1.) I don't know about dbcp but with regards to C3P0 this functionality does exist in the C3P0PooledConnection class (look in the invoke method, the exception is caught and handled, if you want more details on the exact handling I can add them). I also needed to know if it contained it to drop testOnCheckin/Checkout and I verified it contains this behaviour.
2.) Really hard to say, since on the one hand C3P0 is widely used in many production sites and the maintainer has resumed active development but on the other hand BoneCP seems to have some very interesting design principles (pool sharding for examples) and some flattering benchmarks. Since you usually have a pretty good indirection from your connection pool library (mostly the dependency is contained to a config file or two) I can suggest to start with one and once you have a production with actual data try to optimize it and compare it with another library (also optimized of course). It very well may be that either library you choose will be sufficient for your needs.