Hi Slava, 

Thank you so much for your reply it is most helpful!

I'm a little confused by all of this because I have been connecting with 
DBeaver to jdbc:ignite:thin://127.0.0.1/ and I can create tables there if I use 
the predefined templates PARTITIONED or REPLICATED, however, when I try using 
my own templates I simply get SQL Error[50000] "Cache doesn't exist!" - not 
sure why this is happening but maybe I'm not connecting to the right DB? 

Is the jdbc:ignite:thin connection not a connection to the H2 instance used by 
Ignite internally? Is it not "legit" to use this instance to create my tables 
or do I have to use another database?


./t

-----Original Message-----
From: slava.koptilin [mailto:[email protected]] 
Sent: torsdag 11. januar 2018 17.26
To: [email protected]
Subject: Re: Problem enabling read-through on cache - no suitable driver

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/

Reply via email to