Q: Need To Use Dynamic Custom Connection Class for connection pooling in java I am thinking of implementing connection pool for DB Connections using dbcp2.
But I am using different types of custom connection classes.
How can I override the Datasource class to use dynamic custom connection classes(Say MyConnectionClass1, MyConnectionClass2, etc..) based on the input?

A: What you you mean by input?
It's possible you are needed same DatasourceFactory?
public DatasourceFactory {
   public Datasource instance(Object sameParameter) {
      if(// condition one for sameParameter) {
         return new MyConnectionClass1DataSource();
      } else {
         return new MyConnectionClass2DataSource();
      }
   }
}

