ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Igor Sapego <isap...@gridgain.com>
Subject Re: Load data to cache
Date Mon, 27 Mar 2017 12:39:06 GMT
I can't see you putting any value into your cache. If you want to load it
from a
storage you need to call cache.loadCache();

Best Regards,
Igor

On Mon, Mar 27, 2017 at 2:27 PM, kavitha <kavithamrgsn@gmail.com> wrote:

> Okay fine.
> I have NORTHWND sql database. Table name is 'Categories' and their columns
> are CategoryID, CategoryName, Description. My code is below. But I can't
> get
> data. Empty Table only displayed. Can you please say me what I am missing
> here?
>
> using System;
> using System.Collections.Generic;
> using System.Data;
> using System.Data.Common;
> using System.Data.Entity.Migrations.Model;
> using System.Linq;
> using System.Text;
> using System.Threading.Tasks;
> using Apache.Ignite.Core;
> using Apache.Ignite.Core.Events;
> using Apache.Ignite.Core.Binary;
> using System.Data.Odbc;
> using System.IO;
> using System.Net;
> using System.Runtime.CompilerServices;
> using System.Security.Cryptography.X509Certificates;
> using Apache.Ignite.Core.Cache;
> using Apache.Ignite.Core.Cache.Configuration;
> using Apache.Ignite.Core.Cache.Query;
> using Apache.Ignite.Core.Discovery.Tcp;
> using Apache.Ignite.Core.Discovery.Tcp.Static;
> using Apache.Ignite.Core.Services;
> using Apache.Ignite.ExamplesDll.Binary;
> using Apache.Ignite.Core.Cache.Store;
> using Apache.Ignite.Core.Cluster;
> using Apache.Ignite.Core.Common;
> using Apache.Ignite.Core.Compute;
> using Apache.Ignite.Core.Datastream;
>
> namespace CreateCluster
> {
>     [Serializable]
>     public class Categories
>     {
>         public int CategoryID { get; set; }
>         public string CategoryName { get; set; }
>         public string Description { get; set; }
>
>         public Categories()
>         {
>
>         }
>         public Categories(int id, string name, string des)
>         {
>             CategoryID = id;
>             CategoryName = name;
>             Description = des;
>         }
>
>
>     }
>     class Program
>     {
>         static void Main(string[] args)
>         {
>           IIgnite ignite = Ignition.Start(@"F:\Visual
> Studio2015\Projects\CreateCluster\CreateCluster\my-file.xml");
>             var cache = ignite.GetCache<int, Categories>("NORTHWND");
>             OdbcConnection con = new OdbcConnection("DRIVER={Apache
> Ignite};ADDRESS=localhost:10800;CACHE=NORTHWND");
>             con.Open();
>             OdbcCommand cmd = new OdbcCommand("Select * from Categories",
> con);
>             OdbcDataReader dr1 =
> cmd.ExecuteReader(CommandBehavior.SchemaOnly);
>             DataTable table1 = new DataTable();
>             table1.Load(dr1);
>         }
>     }
> }
>
>
> My-file.xml code:
>
> <?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">
>  <bean id="dataSource"
> class="org.springframework.jdbc.datasource.DriverManagerDataSource"/>
>   <bean id="ignite.cfg"
> class="org.apache.ignite.configuration.IgniteConfiguration">
>
>
>     <property name="odbcConfiguration">
>       <bean class="org.apache.ignite.configuration.OdbcConfiguration"/>
>     </property>
> <property name="cacheConfiguration">
>       <list>
>         <bean class="org.apache.ignite.configuration.CacheConfiguration">
>           <property name="name" value="NORTHWND"/>
>            <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="dataSource"/>
>                     <property name="dialect">
>                         <bean
> class="org.apache.ignite.cache.store.jdbc.dialect.SQLServerDialect">
>                         </bean>
>                     </property>
>                     <property name="types">
>                         <list>
>                             <bean
> class="org.apache.ignite.cache.store.jdbc.JdbcType">
>                                 <property name="cacheName"
> value="NORTHWND"/>
>                                 <property name="keyType"
> value="java.lang.Integer"/>
>                                 <property name="valueType"
> value="Categories"/>
>                                 <property name="databaseSchema"
> value="Categories"/>
>                                 <property name="databaseTable"
> value="Categories"/>
> <property name="keyFields">
>                                     <list>
>                                         <bean
> class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
>                                             <constructor-arg>
>                                                 <util:constant
> static-field="java.sql.Types.INTEGER"/>
>                                             </constructor-arg>
>                                             <constructor-arg
> value="CategoryID"/>
>                                             <constructor-arg value="int"/>
>                                             <constructor-arg
> value="Categoryid"/>
>                                         </bean>
>                                     </list>
>                                 </property>
>                                 <property name="valueFields">
>                                     <list>
>                                         <bean
> class="org.apache.ignite.cache.store.jdbc.JdbcTypeField">
>                                             <constructor-arg>
>                                                 <util:constant
> static-field="java.sql.Types.INTEGER"/>
>                                             </constructor-arg>
>                                             <constructor-arg
> value="CategoryID"/>
>                                             <constructor-arg value="int"/>
>                                             <constructor-arg
> value="Categoryid"/>
>                                         </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="CategoryName"/>
>                                             <constructor-arg
> value="java.lang.String"/>
>                                             <constructor-arg
> value="Categoryname"/></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="Description"/>
>                                             <constructor-arg
> value="java.lang.String"/>
>                                             <constructor-arg
> value="Description"/>
>                                         </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="java.lang.Integer"/>
>                 <property name="valueType" value="Categories"/>
> <property name="fields">
>                             <map>
>                                 <entry key="CategoryID"
> value="java.lang.Integer"/>
>                                 <entry key="CategoryName"
> value="java.lang.String"/>
>                                 <entry key="Description"
> value="java.lang.String"/>
>                             </map>
>                         </property>
>
>               </bean>
>             </list>
>           </property>
>         </bean>
>       </list>
>     </property>
>             </bean>
>         </beans>
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Load-data-to-cache-tp11394p11468.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Mime
View raw message