我写了一个单例类来获取数据库连接.
现在我的问题是:假设有100个用户访问该应用程序.如果一个用户关闭了连接,对于其他99个用户,是否会关闭连接?
这是我的示例程序,它使用单例类来获取数据库连接:
public class GetConnection {
private GetConnection() { }
public Connection getConnection() {
Context ctx = new InitialContext();
DataSource ds = ctx.lookup("jndifordbconc");
Connection con = ds.getConnection();
return con;
}
public static GetConnection getInstancetoGetConnection () {
// which gives GetConnection class instance to call getConnection() on this .
}
}
Run Code Online (Sandbox Code Playgroud)
请指导我.