Hi Thomas,
Please make sure that your h2 database is started and required tables are
created.
You can use the following test as example how to do that (please see,
CacheJdbcPojoStoreAbstractSelfTest#beforeTest)
https://github.com/apache/ignite/blob/master/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
Cache configuration should be modified as well.
1. First of all, correct DB connection URL should be provided. For instance,
<bean id="simpleDataSource" class="org.h2.jdbcx.JdbcDataSource">
<property name="URL"
value="jdbc:h2:mem:TestDatabase;DB_CLOSE_DELAY=-1"/>
<property name="user" value="username"/>
<property name="password" value=""/>
</bean>
2. secondly, you need to configure types mapping within the cache
configuration. Let's assume that you have a simple cache
IgniteCache<Integer, String>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="test-cache"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="cacheStoreFactory">
<bean
class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory">
<property name="dataSourceBean" value="storeDataSource"/>
<property name="dialect">
<bean
class="org.apache.ignite.cache.store.jdbc.dialect.H2Dialect"/>
</property>
<property name="types">
<list>
<bean
class="org.apache.ignite.cache.store.jdbc.JdbcType">
<property name="cacheName" value="test-cache"/>
<property name="keyType"
value="java.lang.Integer"/>
<property name="valueType"
value="java.lang.String"/>
<property name="databaseSchema" value="PUBLIC"/>
<property name="databaseTable"
value="testtable"/>
<property name="keyFields">
<list>
<bean
class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
<property name="databaseFieldName"
value="ID"/>
<property name="databaseFieldType">
<util:constant
static-field="java.sql.Types.INTEGER"/>
</property>
<property name="javaFieldName"
value="id"/>
<property name="javaFieldType"
value="java.lang.Integer"/>
</bean>
</list>
</property>
<property name="valueFields">
<list>
<bean
class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
<property name="databaseFieldName"
value="name"/>
<property name="databaseFieldType">
<util:constant
static-field="java.sql.Types.VARCHAR"/>
</property>
<property name="javaFieldName"
value="name"/>
<property name="javaFieldType"
value="java.lang.String"/>
</bean>
</list>
</property>
</bean>
</list>
</property>
</bean>
</property>
</bean>
additional example(s) can be found here:
https://github.com/apache/ignite/blob/master/modules/spring/src/test/config/jdbc-pojo-store-builtin.xml
Thanks,
Slava.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/