-1

Can you please explain how singleton is use full for creating database connection?
How it will work in multithreaded environment while creating db connection and closing the connection? Once connection is closed will it gets disconnect from database?

4

1 回答 1

2

在 Java 应用程序中管理数据库连接时,通常应该使用“连接池”。创建连接是昂贵/繁重的,所以你真的不想一次又一次地创建它们,特别是对于一个繁忙的站点(性能下降会杀死它)。

获取池引用的方式取决于应用程序的类型(像 servlet/JSP 或独立应用程序一样管理),但要搜索“数据源”。也看看这个答案

于 2013-09-08T09:37:43.190 回答