Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public static void main(String[] args) throws Exception {
  2. MysqlDataSource ds = new MysqlDataSource();
  3. ds.setUrl("jdbc:mysql://localhost:3306/db");
  4. ds.setUser("root");
  5. ds.setPassword("root");
  6.  
  7. SimpleRegistry registry = new SimpleRegistry();
  8. registry.put("datasource", ds);
  9.  
  10. CamelContext ctx = new DefaultCamelContext(registry);
  11. ctx.addRoutes(new RouteBuilder() {
  12.  
  13. @Override
  14. public void configure() throws Exception {
  15.  
  16. from("direct:start").to("jdbc:datasource").bean(new ResultHandler(), "printResult");
  17.  
  18. }
  19. });
  20.  
  21. ctx.start();
  22.  
  23. ProducerTemplate template = ctx.createProducerTemplate();
  24. template.sendBody("direct:start", "SELECT * FROM products");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement