how to manage connections to dynamically created databases

前端 未结 2 1553
闹比i
闹比i 2020-12-30 06:02

I need to manage connections to multiple databases in my web app. following are facts regarding the current implementation:

1- I use Tomcat

2- databases are

相关标签:
2条回答
  • 2020-12-30 06:49

    The MySQL JDBC driver allows omitting the database name from the connection URL as follows:

    jdbc:mysql://localhost:3306

    You only need to specify the database by Connection#setCatalog() or directly in the SQL queries. See also its reference documentation:

    If the database is not specified, the connection will be made with no default database. In this case, you will need to either call the setCatalog() method on the Connection instance or fully specify table names using the database name (that is, SELECT dbname.tablename.colname FROM dbname.tablename...) in your SQL. Not specifying the database to use upon connection is generally only useful when building tools that work with multiple databases, such as GUI database managers.

    This allows you for creating a single and reuseable connection pooled datasource in Tomcat. You'll perhaps only need to rewrite your connection manager and/or SQL queries.

    0 讨论(0)
  • 2020-12-30 06:59

    There are enough connection pooling framework in the open. Proxool is definitely among the best. Its pretty flexible and easy to use.

    0 讨论(0)
提交回复
热议问题