(1) I need to connect Esper database adapter to my project. Im using this
as guide, but I do not know where to locate the configuration file because im getting this error: Cannot locate configuration information for database 'db1'
This is what i have
public class Esper {
public void iniciar() {
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider();
ConfigurationDBAdapter adapterConfig = new ConfigurationDBAdapter();
ConfigurationDBRef configDB = new ConfigurationDBRef();
configDB.setDriverManagerConnection("org.postgresql.Driver",
"jdbc:postgresql://localhost:5432/db_name",
"user",
"pass");
adapterConfig.getJdbcConnections().put("db1", configDB);
EsperIODBAdapter dbAdapter = new EsperIODBAdapter(adapterConfig, "engineURI");
dbAdapter.start();
String expression = "select * from pattern[every timer :interval(10)], sql:db1 ['select mosquitoId from registros where velocidad > 50']";
EPStatement stmt = epService.getEPAdministrator().createEPL(expression);
Mylistener listener = new Mylistener();
stmt.addListener(listener);
}
}
(2) What i need to do is get data from table Registros
and if velocidad > 50
use printLn(), i dont understand what is pattern
in the example.
Instead of "EPServiceProviderManager.getDefaultProvider();" you would want to use "EPServiceProviderManager.getDefaultProvider(configuration);".
Configuration configuration = new Configuration();
ConfigurationDBRef configDB = new ConfigurationDBRef();
configDB.setDriverManagerConnection(....);
configuration.addDatabaseReference("MyDB", configDB);
EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);