use of org.apache.calcite.adapter.splunk.search.SplunkConnection in project calcite by apache.
the class SplunkDriver method connect.
@Override
public Connection connect(String url, Properties info) throws SQLException {
Connection connection = super.connect(url, info);
CalciteConnection calciteConnection = (CalciteConnection) connection;
SplunkConnection splunkConnection;
try {
String url1 = info.getProperty("url");
if (url1 == null) {
throw new IllegalArgumentException("Must specify 'url' property");
}
if (url1.equals("mock")) {
splunkConnection = new MockSplunkConnection();
} else {
String user = info.getProperty("user");
if (user == null) {
throw new IllegalArgumentException("Must specify 'user' property");
}
String password = info.getProperty("password");
if (password == null) {
throw new IllegalArgumentException("Must specify 'password' property");
}
URL url2 = new URL(url1);
splunkConnection = new SplunkConnectionImpl(url2, user, password);
}
} catch (Exception e) {
throw new SQLException("Cannot connect", e);
}
final SchemaPlus rootSchema = calciteConnection.getRootSchema();
rootSchema.add("splunk", new SplunkSchema(splunkConnection));
return connection;
}
Aggregations