Thanks, Neven.
It turns out the PostgreSQL JDBC driver does not implement the
setCatalog method, so this option is not available to me. However, I
went ahead and set up my own cache of connection pools (dataSource
instances) in a HashMap, and configured Jersey to persist this across
web service calls. (I also set a single JNDI dataSource for the central
database that manages all the others.) So far, so good.
On 10/26/2014 3:28 PM, Neven Cvetkovic wrote:
Hey Ric,
Here's another thing you could do:
http://stackoverflow.com/questions/7195556/how-to-manage-connections-to-dynamically-created-databases
If your databases are all on the same db instance, but different
schema/database name, you could avoid connecting to the specific database
name, but rather set that up on the connection object, e.g.
@Resource(name="....")
private DataSource datasource;
public void someMethod() {
try
(
Connection c = datasource.getConnection();
c.setCatalog("dynamic_dbname");
PreparedStatement ps = c.prepareStatement("SOME SQL HERE");
)
{
...
} catch (SQLException sqle) {
...
}
}
I haven't tried this myself, but I guess this could work. Off course,
working with Spring JdbcTemplate makes it even nicer :))
How long do these dbs live? How often do you create them? Why do you have a
need for that many databases? etc...
Hope that helps!
Cheers!
Neven
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org