hi ,

Please find the config file for client .

import com.mchange.v2.c3p0.ComboPooledDataSource;
import java.io.InputStream;
import java.math.BigDecimal;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Properties;
import javax.cache.configuration.Factory;
import javax.sql.DataSource;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.QueryEntity;
import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory;
import org.apache.ignite.cache.store.jdbc.JdbcType;
import org.apache.ignite.cache.store.jdbc.JdbcTypeField;
import org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.OdbcConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import
org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
//import com.timesten.jdbc.JdbcOdbcConnection;
//import com.timesten.jdbc.TimesTenDataSource;

public class ClientConfigurationFactory {
    /** Secret properties loading. **/
    private static final Properties props = new Properties();

    static {
        try (InputStream in =
IgniteConfiguration.class.getClassLoader().getResourceAsStream("secret.properties"))
{
            props.load(in);
        }
        catch (Exception ignored) {
            // No-op.
        }
    }

    /** Helper class for datasource creation. **/
    public static class DataSources {
        public static final ComboPooledDataSource INSTANCE_dataStore =
createdataStore();

        private static ComboPooledDataSource createdataStore() {
            ComboPooledDataSource dataStore = new ComboPooledDataSource();


dataStore.setJdbcUrl("jdbc:timesten:client:TTC_Server=localhost;TCP_PORT=53397;TTC_Server_DSN=EMSDSN;UID=test;PWD=test;TTC_Timeout=180");
            dataStore.setUser("kodiak");
            dataStore.setPassword("kodiak");

            return dataStore;
        }
    }


    /**
     * Configure grid.
     *
     * @return Ignite configuration.
     * @throws Exception If failed to construct Ignite configuration
instance.
     **/
    public static IgniteConfiguration createConfiguration() throws
Exception {
        IgniteConfiguration cfg = new IgniteConfiguration();

        cfg.setClientMode(true);
        cfg.setGridName("TestDB1");

        TcpDiscoverySpi discovery = new TcpDiscoverySpi();

        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

        ipFinder.setAddresses(Arrays.asList("127.0.0.1:47500..47510"));

        discovery.setIpFinder(ipFinder);

        cfg.setDiscoverySpi(discovery);

        BinaryConfiguration binaryCfg = new BinaryConfiguration();

        binaryCfg.setCompactFooter(false);

        cfg.setBinaryConfiguration(binaryCfg);

        cfg.setOdbcConfiguration(new OdbcConfiguration());

        cfg.setCacheConfiguration(cacheEmployeeCache());

        return cfg;
    }

    /**
     * Create configuration for cache "EmployeeCache".
     *
     * @return Configured cache.
     * @throws Exception if failed to create cache configuration.
     **/
    public static CacheConfiguration cacheEmployeeCache() throws Exception {
        CacheConfiguration ccfg = new CacheConfiguration();

        ccfg.setName("EmployeeCache");
        ccfg.setCacheMode(CacheMode.PARTITIONED);
        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);

        CacheJdbcPojoStoreFactory cacheStoreFactory = new
CacheJdbcPojoStoreFactory();

        cacheStoreFactory.setDataSourceFactory(new Factory<DataSource>() {
            /** {@inheritDoc} **/
            @Override public DataSource create() {
                return DataSources.INSTANCE_dataStore;
            };
        });

        cacheStoreFactory.setDialect(new BasicJdbcDialect());

        cacheStoreFactory.setTypes(jdbcTypeEmployee(ccfg.getName()));

        ccfg.setCacheStoreFactory(cacheStoreFactory);

        ccfg.setReadThrough(true);
        ccfg.setWriteThrough(true);

        ArrayList<QueryEntity> qryEntities = new ArrayList<>();

        QueryEntity qryEntity = new QueryEntity();

        qryEntity.setKeyType("com.gmail.orl.debasis.model.EmployeeKey");
        qryEntity.setValueType("com.gmail.orl.debasis.model.Employee");

        LinkedHashMap<String, String> fields = new LinkedHashMap<>();

        fields.put("id", "java.math.BigDecimal");
        fields.put("firstname", "java.lang.String");
        fields.put("lastname", "java.lang.String");

        qryEntity.setFields(fields);
        qryEntities.add(qryEntity);

        ccfg.setQueryEntities(qryEntities);

        return ccfg;
    }

    /**
     * Create JDBC type for "jdbcTypeEmployee".
     *
     * @param cacheName Cache name.
     * @return Configured JDBC type.
     **/
    private static JdbcType jdbcTypeEmployee(String cacheName) {
        JdbcType type = new JdbcType();

        type.setCacheName(cacheName);
        type.setKeyType("com.gmail.orl.debasis.model.EmployeeKey");
        type.setValueType("com.gmail.orl.debasis.model.Employee");
        type.setDatabaseSchema("DG");
        type.setDatabaseTable("EMPLOYEE");

        type.setValueFields(
            new JdbcTypeField(Types.DECIMAL, "ID", BigDecimal.class, "id"),
            new JdbcTypeField(Types.VARCHAR, "FIRSTNAME", String.class,
"firstname"),
            new JdbcTypeField(Types.VARCHAR, "LASTNAME", String.class,
"lastname")
        );

        return type;
    }
}

******************
client-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:util="http://www.springframework.org/schema/util";
       xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/util

http://www.springframework.org/schema/util/spring-util.xsd";>
    <!-- Load external properties file. -->
    <bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location" value="classpath:secret.properties"/>
    </bean>

    <!-- Data source beans will be initialized from external properties
file. -->
     <bean id="dataStore" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="jdbcUrl" value="${dataStore.jdbc.url}"/>
        <property name="user" value="${dataStore.jdbc.username}"/>
        <property name="password" value="${dataStore.jdbc.password}"/>
    </bean>

    <!-- Data source beans will be initialized from external properties
file. -->
  <!-- <bean id="dataStore" class="com.timesten.jdbc.TimesTenDataSource">
        <property name="jdbcUrl"
value="jdbc:timesten:client:TTC_Server=localhost;TCP_PORT=53397;TTC_Server_DSN=emsdsn;UID=kodiak;PWD=kodiak;TTC_Timeout=180"/>
        <property name="user" value="kodiak"/>
        <property name="password" value="kodiak"/>
    </bean>-->

    <bean class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="clientMode" value="false"/>
        <property name="gridName" value="TestDB1"/>

        <property name="discoverySpi">
            <bean
class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1:47500..47510</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>

        <property name="binaryConfiguration">
            <bean
class="org.apache.ignite.configuration.BinaryConfiguration">
                <property name="compactFooter" value="false"/>
            </bean>
        </property>

        <property name="odbcConfiguration">
            <bean class="org.apache.ignite.configuration.OdbcConfiguration">
            </bean>
        </property>

        <property name="cacheConfiguration">
            <list>
                <bean
class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="EmployeeCache"/>
                    <property name="cacheMode" value="PARTITIONED"/>
                    <property name="atomicityMode" value="ATOMIC"/>

                    <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory">
                            <property name="dataSourceBean"
value="dataStore"/>
                            <property name="dialect">
                                <bean
class="org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect">
                                </bean>
                            </property>

                            <property name="types">
                                <list>
                                    <bean
class="org.apache.ignite.cache.store.jdbc.JdbcType">
                                        <property name="cacheName"
value="EmployeeCache"/>
                                        <property name="keyType"
value="com.gmail.orl.debasis.model.EmployeeKey"/>
                                        <property name="valueType"
value="com.gmail.orl.debasis.model.Employee"/>
                                        <property name="databaseSchema"
value="DG"/>
                                        <property name="databaseTable"
value="EMPLOYEE"/>

                                        <property name="valueFields">
                                            <list>
                                                <bean
class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant
static-field="java.sql.Types.DECIMAL"/>
                                                    </constructor-arg>
                                                    <constructor-arg
value="ID"/>
                                                    <constructor-arg
value="java.math.BigDecimal"/>
                                                    <constructor-arg
value="id"/>
                                                </bean>

                                                <bean
class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant
static-field="java.sql.Types.VARCHAR"/>
                                                    </constructor-arg>
                                                    <constructor-arg
value="FIRSTNAME"/>
                                                    <constructor-arg
value="java.lang.String"/>
                                                    <constructor-arg
value="firstname"/>
                                                </bean>

                                                <bean
class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
                                                    <constructor-arg>
                                                        <util:constant
static-field="java.sql.Types.VARCHAR"/>
                                                    </constructor-arg>
                                                    <constructor-arg
value="LASTNAME"/>
                                                    <constructor-arg
value="java.lang.String"/>
                                                    <constructor-arg
value="lastname"/>
                                                </bean>
                                            </list>
                                        </property>
                                    </bean>
                                </list>
                            </property>
                        </bean>
                    </property>

                    <property name="readThrough" value="true"/>
                    <property name="writeThrough" value="true"/>

                    <property name="queryEntities">
                        <list>
                            <bean
class="org.apache.ignite.cache.QueryEntity">
                                <property name="keyType"
value="com.gmail.orl.debasis.model.EmployeeKey"/>
                                <property name="valueType"
value="com.gmail.orl.debasis.model.Employee"/>

                                <property name="fields">
                                    <map>
                                        <entry key="id"
value="java.math.BigDecimal"/>
                                        <entry key="firstname"
value="java.lang.String"/>
                                        <entry key="lastname"
value="java.lang.String"/>
                                    </map>
                                </property>
                            </bean>
                        </list>
                    </property>
                </bean>
            </list>
        </property>
    </bean>
</beans>

On Tue, May 23, 2017 at 4:34 PM, Evgenii Zhuravlev <[email protected]
> wrote:

> Hi,
>
> Could you provide your full config file?
>
> 2017-05-22 15:00 GMT+03:00 debasish pradhan <[email protected]>:
>
>> Hi ,
>>
>> I am new to apache ignite. I was trying to connect Timesten DB to fetch
>> data , but its failing . I downloaded the project from web console . As per
>> instruction I started the server node . After that I am trying to run
>> loadcache . but its failing with following error.
>>
>> cache load code:
>> =========
>>
>> *try* (Ignite ignite = Ignition.*start*("TestDB1-client.xml")) {
>>
>> System.*out*.println(">>> Loading caches...");
>>
>> System.*out*.println(">>> Loading cache:...EmployeeCache");
>>
>> //ignite.cache("EmployeeCache").loadCache(null);
>>
>> ignite.cache("EmployeeCache").loadCache(*null*, Employee.*class*.getName(),
>> "select * from DG.Employee");
>>
>>
>> configuration:jdbc driver :
>>
>>     public static class DataSources {
>>         public static final TimesTenDataSource INSTANCE_dataStore =
>> createdataStore();
>>         private static TimesTenDataSource createdataStore() {
>>          TimesTenDataSource dataStore = new TimesTenDataSource();
>>             dataStore.setUrl("jdbc:timesten:client:TTC_Server=localhost;
>> TCP_PORT=53397;TTC_Server_DSN=TESTDSN;UID=test;PWD=test;TTC_
>> Timeout=180");
>>             dataStore.setUser("test");
>>             dataStore.setPassword("test");
>>             return dataStore;
>>         }
>>     }
>>
>>
>> TestDB1-client.xml-->
>>
>> <bean id="dataSource" class="com.timesten.jdbc.TimesTenDataSource">
>> <property name="url" value="jdbc:timesten:client:TT
>> C_Server=localhost;TCP_PORT=53397;TTC_Server_DSN=TestDSN;UID
>> =test;PWD=test;TTC_Timeout=180" />
>> <property name="username" value="kodiak" />
>> <property name="password" value="kodiak" />
>> </bean>
>>
>> [17:04:12,860][SEVERE][main][GridJobWorker] Failed to execute job
>> [jobId=1a08fef2c51-8b249f71-34cd-4ec7-8056-c32a3e61034b,
>> ses=GridJobSessionImpl [ses=GridTaskSessionImpl
>> [taskName=o.a.i.i.processors.cache.GridCacheAdapter$LoadCacheJobV2,
>> dep=LocalDeployment [super=GridDeployment [ts=1495452846874,
>> depMode=SHARED, clsLdr=sun.misc.Launcher$AppClassLoader@4e0e2f2a,
>> clsLdrId=6608fef2c51-8b249f71-34cd-4ec7-8056-c32a3e61034b, userVer=0,
>> loc=true, sampleClsName=java.lang.String, pendingUndeploy=false,
>> undeployed=false, usage=0]], taskClsName=o.a.i.i.processors
>> .cache.GridCacheAdapter$LoadCacheJobV2, 
>> sesId=0a08fef2c51-8b249f71-34cd-4ec7-8056-c32a3e61034b,
>> startTime=1495452852829, endTime=9223372036854775807,
>> taskNodeId=8b249f71-34cd-4ec7-8056-c32a3e61034b,
>> clsLdr=sun.misc.Launcher$AppClassLoader@4e0e2f2a, closed=false,
>> cpSpi=null, failSpi=null, loadSpi=null, usage=1, fullSup=false,
>> internal=true, subjId=8b249f71-34cd-4ec7-8056-c32a3e61034b,
>> mapFut=IgniteFuture [orig=GridFutureAdapter [resFlag=0, res=null,
>> startTime=1495452852839, endTime=0, ignoreInterrupts=false, state=INIT]]],
>> jobId=1a08fef2c51-8b249f71-34cd-4ec7-8056-c32a3e61034b]]
>>
>> class *org.apache.ignite.IgniteException*:
>> *java.lang.NullPointerException*
>>
>> at org.apache.ignite.internal.processors.closure.GridClosurePro
>> cessor$C2V2.execute(*GridClosureProcessor.java:2059*)
>>
>> at org.apache.ignite.internal.processors.job.GridJobWorker$2.call(
>> *GridJobWorker.java:560*)
>>
>> at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(
>> *IgniteUtils.java:6620*)
>>
>> at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(
>> *GridJobWorker.java:554*)
>>
>> at org.apache.ignite.internal.processors.job.GridJobWorker.body(
>> *GridJobWorker.java:483*)
>>
>> at org.apache.ignite.internal.util.worker.GridWorker.run(
>> *GridWorker.java:110*)
>>
>> at org.apache.ignite.internal.processors.job.GridJobProcessor.p
>> rocessJobExecuteRequest(*GridJobProcessor.java:1114*)
>>
>> at org.apache.ignite.internal.processors.task.GridTaskWorker.sendRequest(
>> *GridTaskWorker.java:1383*)
>>
>> at org.apache.ignite.internal.processors.task.GridTaskWorker.pr
>> ocessMappedJobs(*GridTaskWorker.java:645*)
>>
>> at org.apache.ignite.internal.processors.task.GridTaskWorker.body(
>> *GridTaskWorker.java:537*)
>>
>> at org.apache.ignite.internal.util.worker.GridWorker.run(
>> *GridWorker.java:110*)
>>
>> at org.apache.ignite.internal.processors.task.GridTaskProcessor
>> .startTask(*GridTaskProcessor.java:679*)
>>
>> at org.apache.ignite.internal.processors.task.GridTaskProcessor.execute(
>> *GridTaskProcessor.java:403*)
>>
>> at org.apache.ignite.internal.processors.closure.GridClosurePro
>> cessor.callAsync(*GridClosureProcessor.java:418*)
>>
>> at org.apache.ignite.internal.processors.closure.GridClosurePro
>> cessor.callAsync(*GridClosureProcessor.java:391*)
>>
>> at org.apache.ignite.internal.processors.cache.GridCacheAdapter
>> .globalLoadCacheAsync(*GridCacheAdapter.java:3718*)
>>
>> at org.apache.ignite.internal.processors.cache.GridCacheAdapter
>> .globalLoadCache(*GridCacheAdapter.java:3657*)
>>
>> at org.apache.ignite.internal.processors.cache.IgniteCacheProxy
>> .loadCache(*IgniteCacheProxy.java:390*)
>>
>> at load.LoadCaches.main(*LoadCaches.java:28*)
>>
>>
>>
>>
>

Reply via email to