> 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".
My bad: I copied some code around and dropped the "new." You are quite right: I am calling the constructor. > No. A constructor creates a new object. Of course, I realize a constructor creates a new object. However, I had assumed that connections opened from two separate DataSource instances would still coexist in the same Tomcat connection pool. To confirm: you are saying that one DataSource instance == one connection pool, period. Right? So connections from separate DataSource objects can never share the same connection pool. In the context of a JAX-RS application, this means I must persist my DataSource instances in memory across web service calls (which is fine, I can do that), and reuse them. Otherwise I simply am not getting any connection pooling at all. Right? Thanks, I really appreciate the input. As you can see, I had some fundamental misunderstandings. -----Original Message----- From: Konstantin Kolinko [mailto:knst.koli...@gmail.com] Sent: Saturday, October 25, 2014 2:14 PM To: Tomcat Users List Subject: Re: Tomcat 7 JDBC Connection Pool - question about usage from Java code 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_Jav > a > > 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 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org