When I am writing connection pool to connect to database, I am always confused about the difference of using a Driver-based connection or a DataSource-based connection. It seems both of them can get the things done, but I am not sure of their difference. Can anyone tell me about it, or give me some kind of links?
Thanks in advance.
DataSourceandDriverare not comparable –DataSourceandDriverManagerare.Driveris the basic construct of JDBC, and isn’t going anywhere. The JDBC driver implementation provides this.DriverManageris old, inflexible and unofficially deprecated:So your primary interface to interact with for your pool is
DataSource, notDriverManager. TheDriverclass will still be used, however.Incidentally, why are you writing your own connection pool? There are (at least) two high quality open-source implementations out there already (DBCP and C3P0).