title: How to uniquely name an object
body: <p>I have a simple webapp that acquires connection from tomcat JDBC datasource. To track the connection usage, I'm planning to implement logging while opening and closing connection. The logging supposed to print something like this.</p>
  
  <pre><code>20151230143623.947[Thread-3] INFO  [DataSourceManager:19] Opened connection identified by id : BlahBlahBlah1
  20151230143623.947[Thread-3] INFO  [DataSourceManager:19] Closed connection identified by id : BlahBlahBlah1
  </code></pre>
  
  <p>My open and close methods are like this.</p>
  
  <pre><code>Connection openConnection(String JNDILookupName) throws Exception {
      Connection connection = DataSourceManager.getConnection(JNDILookupName);
      logDBOperation("Opened", connection.toString());
      return connection;
  }
  Connection closeConnection(String JNDILookupName) throws Exception {
      connection.close();
      logDBOperation("Closed", connection.toString());
  }
  void logDBOperation(String operation, String connecitonName){
      logger.info(operation+" connection identified by id : "+connectionName);
  }
  </code></pre>
  
  <p>Here I'm using <code>connection.toString()</code> as the Connection's unique name in the Logs. But I want to know if there is any better way to do this.</p>