com.newrelic.agent.bridge.datastore.JdbcDatabaseVendor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agent-bridge-datastore Show documentation
Show all versions of agent-bridge-datastore Show documentation
The bridge datastore API of the Java agent.
The newest version!
/*
*
* * Copyright 2020 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/
package com.newrelic.agent.bridge.datastore;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.LinkedList;
public abstract class JdbcDatabaseVendor implements DatabaseVendor {
protected final String name;
protected String type;
protected boolean explainPlanSupported;
public JdbcDatabaseVendor(String name, String type, boolean explainSupported) {
this.name = name;
this.type = type;
this.explainPlanSupported = explainSupported;
}
public String getName() {
return name;
}
public String getType() {
return type;
}
public boolean isExplainPlanSupported() {
return explainPlanSupported;
}
public String getExplainPlanSql(String sql) throws SQLException {
if (!isExplainPlanSupported()) {
throw new SQLException("Unable to run explain plans for " + getName() + " databases");
}
return "EXPLAIN " + sql;
}
/**
* Parse an explain plan result set and return a collection of collections representing it.
*
* @param recordSql
*/
public Collection> parseExplainPlanResultSet(int columnCount, ResultSet rs, RecordSql recordSql)
throws SQLException {
Collection> explains = new LinkedList<>();
while (rs.next()) {
Collection
© 2015 - 2025 Weber Informatics LLC | Privacy Policy