2014-10-25 23:12 GMT+04:00 Ric Bernat <r...@brinydeep.net>: > I am using Tomcat 7.0.53, and I am using Tomcat JDBC connection pooling to > connect to multiple PostgreSQL (9.3) databases. My application is a JAX-RS > (Jersey) web server application that provides a set RESTful web services (no > UI). My data layer uses the Spring JdbcTemplate library. > > First, let me say that I have everything working, and I am moving on to > tuning and optimization. I have read the Tomcat JDBC connection pool docs, > searched the web, asked a question on SO, and am still struggling with a > fairly basic concept or two. > > My Java code looks pretty much like the "Plain Ol' Java" example from the > docs here: > > http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#Plain_Ol%27_Java > > As I said, my questions are fairly fundamental, so let me state my first, > fairly safe, assumption to get this started. Please let me know if this > assumption holds water. > > Assumption #1: If I run code like this twice,|the two resulting connections > will come from the same Tomcat connection pool, even though I am > instantiating two separate instances of |||PoolProperties|, each on a > separate thread in response to a separate JAX-RS web request. > > PoolProperties poolProperties = new PoolProperties(); > ||||poolProperties.setDriverClassName("org.postgresql.Driver"); > ||||poolProperties.setUrl("jdbc:postgresql://myserver/db_a"); > ||||poolProperties.setMaxActive(10); > ||||DataSource dataSource = > org.apache.tomcat.jdbc.pool.DataSource(poolProperties);
There is no such method to be called like on the above line. "DataSource(PoolConfiguration)" is a constructor. To call a constructor you need the keyword "new". > ||||NamedParameterJdbcTemplate namedParameterJdbcTemplate = new > NamedParameterJdbcTemplate(dataSource); > > To restate: I am assuming the two database connections for two separate > calls of this above code will both come from a single Tomcat JDBC connection > pool. Is this assumption correct? No. A constructor creates a new object. Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org