While running in Application Server the DataSource instance might be managed by app server and registered with JNDI. To enable lookup of DataSource instance from JNDI you can configure JNDIDataSourceFactory
Configure the DataSource from OSGi config for PID org.apache.sling.datasource.JNDIDataSourceFactory
Provide the JNDI name to lookup from and other details
However - as i have pointed out, AEM is not a Spring based framework and therefore to connect to a database, one should work in the way that AEM connects to databases - which is using a DATASOURCEPOOL.