Advertisement
Guest User

Untitled

a guest
Apr 10th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. private static class MySQLDemoStoreFactory<K, V> extends CacheJdbcPojoStoreFactory<K, V> {
  2. //{@inheritDoc}
  3. @Override public CacheJdbcPojoStore<K, V> create() {
  4.  
  5.  
  6. MysqlDataSource dataSource = new MysqlDataSource();
  7. dataSource.setURL("jdbc:mysql://localhost/DB");
  8. dataSource.setUser("root");
  9. dataSource.setPassword("pass");
  10. setDataSource(dataSource);
  11. return super.create();
  12.  
  13. }
  14.  
  15. }
  16.  
  17. try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
  18. // Configure cache store.
  19. CacheConfiguration<EmployeeKey, Employee> cfg =
  20. CacheConfig.cache("EmpCache", new MySQLDemoStoreFactory<EmployeeKey, Employee>());
  21.  
  22. try (IgniteCache<EmployeeKey, Employee> cache = ignite.getOrCreateCache(cfg)) {
  23. // Preload cache from database.
  24. preload(cache);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement