in src/main/java/org/apache/sling/datasource/internal/DriverDataSource.java [70:109]
public Connection getConnection(String usr, String pwd) throws SQLException {
Properties properties = PoolUtilities.clone(poolProperties.getDbProperties());
if(usr == null){
usr = poolProperties.getUsername();
}
if(pwd == null){
pwd= poolProperties.getPassword();
}
if (usr != null) properties.setProperty(PoolUtilities.PROP_USER, usr);
if (pwd != null) properties.setProperty(PoolUtilities.PROP_PASSWORD, pwd);
String driverURL = poolProperties.getUrl();
Connection connection;
try {
connection = getDriver().connect(driverURL, properties);
} catch (Exception x) {
if (log.isDebugEnabled()) {
log.debug("Unable to connect to database.", x);
}
//Based on logic in org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver()\
org.apache.tomcat.jdbc.pool.jmx.ConnectionPool jmxPool = getJmxPool();
if (jmxPool !=null) {
jmxPool.notify(org.apache.tomcat.jdbc.pool.jmx.ConnectionPool.NOTIFY_CONNECT,
ConnectionPool.getStackTrace(x));
}
if (x instanceof SQLException) {
throw (SQLException)x;
} else {
SQLException ex = new SQLException(x.getMessage());
ex.initCause(x);
throw ex;
}
}
if (connection==null) {
throw new SQLException("Driver:"+driver+" returned null for URL:"+driverURL);
}
return connection;
}