I always get the following exception when trying to connect to a mariDB database and i cannot figure out how to properly define the dataSource.
No bean could be found in the registry for: myDataSource of type: javax.sql.DataSource
My code is fairly simple and looks like the following:
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
String url = "jdbc:mariadb://localhost:3306/testDB";
BasicDataSource ds = new BasicDataSource();
ds.setUsername("user");
ds.setDriverClassName("com.mysql.jdbc.Driver");
ds.setPassword("password");
ds.setUrl(url);
SimpleRegistry registry = new SimpleRegistry();
registry.put("myDataSource", ds);
CamelContext context = new DefaultCamelContext(registry);
this.setContext(context);
//poll the mySQL Database every x minutes.
from("timer://Timer?period=6000")
.to("sql:select * from testDB?dataSource=myDataSource");
}
};
}
I have already tried the Blueprint version of defining the dataSource, but could not get that to run either.
Is this set up in the correct way? may i be missing a dependency or do i have the wrong drivers specified?