Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static class MySQLDemoStoreFactory<K, V> extends CacheJdbcPojoStoreFactory<K, V> {
- //{@inheritDoc}
- @Override public CacheJdbcPojoStore<K, V> create() {
- MysqlDataSource dataSource = new MysqlDataSource();
- dataSource.setURL("jdbc:mysql://localhost/DB");
- dataSource.setUser("root");
- dataSource.setPassword("pass");
- setDataSource(dataSource);
- return super.create();
- }
- }
- try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- // Configure cache store.
- CacheConfiguration<EmployeeKey, Employee> cfg =
- CacheConfig.cache("EmpCache", new MySQLDemoStoreFactory<EmployeeKey, Employee>());
- try (IgniteCache<EmployeeKey, Employee> cache = ignite.getOrCreateCache(cfg)) {
- // Preload cache from database.
- preload(cache);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement