Thanks a lot Kasnacheev, 

I have used the below mysqlDataSource, but still met the exception, any
ideas? thanks a lot.

'org.apache.ignite.IgniteException: Failed to initialize cache store (data
source is not provided).'

public void setJdbcStoreConfig(CacheConfiguration config) {
        System.out.println("start to connect to mysql ...");
        CacheJdbcPojoStoreFactory cacheJdbcPojoStoreFactory = new
CacheJdbcPojoStoreFactory<>();

        MysqlDataSource mysqlDataSource = new MysqlDataSource();
       
mysqlDataSource.setUrl("jdbc:mysql://127.0.0.1:3306/userdb?useUnicode=true&characterEncoding=utf8");
        mysqlDataSource.setUser("user-a");
        mysqlDataSource.setPassword("admin");

        cacheJdbcPojoStoreFactory.setDialect(new MySQLDialect());
        cacheJdbcPojoStoreFactory.setDataSource(mysqlDataSource);
        JdbcType jdbcType = new JdbcType();
        jdbcType.setCacheName(Balance.class.getSimpleName());
        jdbcType.setDatabaseTable("balance");
        cacheJdbcPojoStoreFactory.setTypes(jdbcType);
        config.setCacheStoreFactory(cacheJdbcPojoStoreFactory);
        config.setWriteThrough(true);
        config.setReadThrough(true);

        QueryEntity queryEntity = new QueryEntity();
        queryEntity.setKeyType("java.lang.String");
        queryEntity.setValueType("com.marble.common.ignite.entity.Balance");
        queryEntity.setKeyFieldName("id");

        LinkedHashMap<String, String> map = new LinkedHashMap<>();
        map.put("account_id", "java.lang.Long");
        map.put("instrument_id", "java.lang.String");
        map.put("quantity", "java.math.BigDecimal");
        map.put("reserved", "java.math.BigDecimal");
        map.put("last_updated", "java.sql.Timestamp");
        map.put("last_Updated_Event", "java.lang.String");
        map.put("trade_type", "java.lang.String");

        queryEntity.setFields(map);
        Collection<QueryEntity> queryEntities = new
ArrayList<QueryEntity>();
        queryEntities.add(queryEntity);

        config.setQueryEntities(queryEntities);
    }



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to