Does getConnection always open a new connection?

Viewed 833

I have found this method in a Java file and I am wondering what's happening here? Does this really work? I think this method does nothing because the getConnection()-method creates a new connection and then it gets closed. Am I correct?

public void closeAllConnections()
    {
        for(String db : this.dbList)
            try {
                DataSource ds = (DataSource) this.applicationContext.getBean(db+"DataSource"); 
                ds.getConnection().close();
            } catch (Exception e) {
                //...
            }
    }
1 Answers
Related