Apache Ignite JDBC瘦客户端无法与现有缓存一起使用
我已经创建了一个Ignite缓存“contact”,并在其中添加了“Person”对象。 当我使用IgniteJDBC客户机模式时,我能够查询这个缓存。但是当我实现JDBC瘦客户机时,它说TablePerson不存在。 我尝试了以下方式进行查询:Apache Ignite JDBC瘦客户端无法与现有缓存一起使用,ignite,Ignite,我已经创建了一个Ignite缓存“contact”,并在其中添加了“Person”对象。 当我使用IgniteJDBC客户机模式时,我能够查询这个缓存。但是当我实现JDBC瘦客户机时,它说TablePerson不存在。 我尝试了以下方式进行查询: Select * from Person Select * from contact.Person 两者都不适用于瘦客户机。我使用的是Ignite 2.1。 感谢您在如何使用瘦客户端查询现有缓存方面提供的帮助。 多谢各位 在default conf
Select * from Person
Select * from contact.Person
两者都不适用于瘦客户机。我使用的是Ignite 2.1。
感谢您在如何使用瘦客户端查询现有缓存方面提供的帮助。
多谢各位
在default config.xml中缓存配置
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<!-- Enabling Apache Ignite Persistent Store. -->
<property name="persistentStoreConfiguration">
<bean class="org.apache.ignite.configuration.PersistentStoreConfiguration"/>
</property>
<property name="binaryConfiguration">
<bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="compactFooter" value="false"/>
</bean>
</property>
<property name="memoryConfiguration">
<bean class="org.apache.ignite.configuration.MemoryConfiguration">
<!-- Setting the page size to 4 KB -->
<property name="pageSize" value="#{4 * 1024}"/>
</bean>
</property>
<!-- Explicitly configure TCP discovery SPI to provide a list of initial nodes. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<value>127.0.0.1:55500..55502</value>
</list>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</beans>
如果要使用SQL查询现有缓存中的数据,应在缓存配置中指定SQL架构。在创建缓存之前添加以下代码:
cc.setSqlSchema(“PUBLIC”);
注意,您已经配置了持久性,所以当您执行
ignite.getOrCreateCache(cc)时代码>如果已保留具有此名称的缓存,则不会应用新配置。例如,您应该删除持久性数据或使用createCache(…)
方法。能否共享缓存配置和jdbc连接字符串?Denis,请查看缓存配置和jdbc URL。谢谢你的帮助。嗨,丹尼斯,你有什么解决方案可以推荐吗?谢谢,丹尼斯,这很有道理。我将尝试将sqlSchema设置为Public,然后查看。非常感谢您的快速回答。
CacheConfiguration<Long, Person> cc = new CacheConfiguration<>(cacheName);
cc.setCacheMode(CacheMode.REPLICATED);
cc.setRebalanceMode(CacheRebalanceMode.ASYNC);
cc.setIndexedTypes(Long.class, Person.class);
cache = ignite.getOrCreateCache(cc);
Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
// Open the JDBC connection.
Connection conn = DriverManager.getConnection("jdbc:ignite:thin://192.168.1.111:10800");
Statement st = conn.createStatement();