Web app runs on Tomcat. Datasource is configured with Spring configuration,
and is used by Hibernate.
If we cannot use JNDI, what would you suggest to use as a DataSource?
org.springframework.jdbc.datasource.DriverManagerDataSource will be ok?
It’s not very good, but sincerely speaking, it can be used on production server, right?
Just a bit of headache with too frequent connection reopening.
Also, we can use BasicDataSource from Apache.
It’s much better of course, but here’s the question. IF WE DON’T USE JNDI, THEN:
If every instance of an app will create its own copy of a DataSource, and every DataSource
can have 5 open connections, what do we get?
Num_of_running_apps * Num_of_max_active_connections = max active open connection on a DB for this user?
Second question: from the perspective of Hibernate, is there any difference about what datasource implementation is used? Will it work with no matter what datasource perfectly and in a stable way?
Certainly not
org.springframework.jdbc.datasource.DriverManagerDataSourcein production, this class is just not a connection pool as written in the javadoc:Use a standalone connection pool like C3P0 or DBPC. Personally, I would go for C3P0 which is known to behave better than DBCP. Have a look at c3p0 vs. dbcp on the Spring forums and this previous question here on SO.
Total # of connections = # of instances of the application x 5
There is no difference. Hibernate will use the connection it gets from Spring.