You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by vkulichenko <va...@gmail.com> on 2016/09/15 00:20:47 UTC

Re: CacheJDBCStore creation failing using MySQL Datasource

Hi,

Please properly subscribe to the mailing list so that the community can
receive email notifications for your messages. To subscribe, send empty
email to user-subscribe@ignite.apache.org and follow simple instructions in
the reply.


vpmavuri wrote
> Hi 
> I am new to Apache Ignite.  Looking for data fabric solutions for one of
> my projects.  I am trying to do POC to create CacheJDBCStore using one of
> the examples from the installation.  Only modification that I am
> attempting to do is to change the datasource from H2 driver to MySQL.  I
> am getting the following error when I ran my example.  Can someone help
> what am I missing?  Any clue or help is highly appreciated.

This happens because you're creating the data source for the session
listener outside of the factory. This means that the data source will be
serialized which you should avoid. You should create the data source within
the Factory.create() method.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/CacheJDBCStore-creation-failing-using-MySQL-Datasource-tp7716p7757.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: CacheJDBCStore creation failing using MySQL Datasource

Posted by Vasiliy Sisko <vs...@gridgain.com>.
Hello @vpmavuri

We already discuss using of data source in thread
http://apache-ignite-users.70518.x6.nabble.com/CacheJdbcPojoStoreExampleFactory-for-Maria-DB-td7479.html

The idiomatic ways of data source usage with CacheJdbcPojoStoreFactory are
specification of data source bean name or implementation of data source
factory class. 

NOTE: When you implement data source bean factory class it should be
available in classpath for every node. F.e.: 

    public class MyDataSourceFactory implements Factory<DataSource> { 
        @Override public DataSource create() { 
            JdbcDataSource dataSource = new JdbcDataSource(); 
            dataSource.setURL("jdbc:..."); 
            dataSource.setUser("username"); 
            dataSource.setPassword("password"); 
            return dataSource; 
        } 
    } 
… 
CacheJdbcPojoStoreFactory storeFactoryJdbcPojo = new
CacheJdbcPojoStoreFactory(); 

storeFactoryJdbcPojo.setDataSourceFactory(new MyDataSourceFactory()); 
… 
NOTE: When you specify data source bean name bean with that name should be
described in spring configuration for every node. F.e: 
    
    
    <bean id="h2Jdbc" class="org.h2.jdbcx.JdbcDataSource">
        <property name="URL" value="${h2Jdbc.jdbc.url}"/>
        <property name="user" value="${h2Jdbc.jdbc.username}"/>
        <property name="password" value="${h2Jdbc.jdbc.password}"/>
    </bean>

... 
    <property name=&quot;cacheStoreFactory 
        &lt;bean
class=&quot;org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory&quot;>
            <property name="dataSourceBean" value="h2Jdbc"/>
        </bean>
    </property>
… 



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/CacheJDBCStore-creation-failing-using-MySQL-Datasource-tp7716p7759.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.