use of com.newrelic.agent.bridge.datastore.JdbcDriverConnectionFactory in project newrelic-java-agent by newrelic.
the class Driver_Weaved method connect.
public Connection connect(String url, Properties props) {
boolean firstInConnectPath = !DatastoreInstanceDetection.shouldDetectConnectionAddress();
try {
DatastoreInstanceDetection.detectConnectionAddress();
Connection connection = Weaver.callOriginal();
DatastoreInstanceDetection.associateAddress(connection);
if (!JdbcHelper.connectionFactoryExists(connection)) {
String detectedUrl = JdbcHelper.getConnectionURL(connection);
if (detectedUrl == null) {
return connection;
}
// Detect correct vendor type and then store new connection factory based on URL
DatabaseVendor vendor = JdbcHelper.getVendor(getClass(), detectedUrl);
JdbcHelper.putConnectionFactory(detectedUrl, new JdbcDriverConnectionFactory(vendor, (Driver) this, url, props));
}
return connection;
} finally {
if (firstInConnectPath) {
DatastoreInstanceDetection.stopDetectingConnectionAddress();
}
}
}
use of com.newrelic.agent.bridge.datastore.JdbcDriverConnectionFactory in project newrelic-java-agent by newrelic.
the class Driver_Instrumentation method connect.
public Connection connect(String url, Properties props) throws SQLException {
boolean firstInConnectPath = !DatastoreInstanceDetection.shouldDetectConnectionAddress();
try {
DatastoreInstanceDetection.detectConnectionAddress();
Connection connection = Weaver.callOriginal();
DatastoreInstanceDetection.associateAddress(connection);
if (!JdbcHelper.connectionFactoryExists(connection)) {
String detectedUrl = JdbcHelper.getConnectionURL(connection);
if (detectedUrl == null) {
return connection;
}
// Detect correct vendor type and then store new connection factory based on URL
DatabaseVendor vendor = JdbcHelper.getVendor(getClass(), detectedUrl);
JdbcHelper.putConnectionFactory(detectedUrl, new JdbcDriverConnectionFactory(vendor, (java.sql.Driver) this, url, props));
}
return connection;
} finally {
if (firstInConnectPath) {
DatastoreInstanceDetection.stopDetectingConnectionAddress();
}
}
}
Aggregations