ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe CEROU <philippe.ce...@gfi.fr>
Subject RE: Sample configuration for one cache [name=KSDATA] and use it with JDBC (client do not find schema)
Date Thu, 06 Dec 2018 15:08:59 GMT
Hi,

I had in fact two problems, the cache BEAN section was not in the good place in the XML (Ignite
return no error) and the name of the cache was in lowercase in XML vs interpreted as uppercas
in client JDBC.

Here is the good 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"
xsi:schemaLocation="     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans.xsd">
  <!--
                                Alter configuration below as needed.
                -->
  <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
    <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>10.200.2.102</value><value>10.200.2.105</value><value>10.200.4.103</value><value>10.200.4.106</value><value>10.200.6.101</value><value>10.200.6.104</value>
              </list>
            </property>
          </bean>
        </property>
      </bean>
    </property>
    <property name="dataStorageConfiguration">
      <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
        <property name="defaultDataRegionConfiguration">
          <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
            <property name="persistenceEnabled" value="true"/>
          </bean>
        </property>
      </bean>
    </property>
    <property name="communicationSpi">
      <bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
        <property name="localPort" value="4321"/>
      </bean>
    </property>
    <property name="authenticationEnabled" value="true"/>

    <property name="cacheConfiguration">
      <list>
        <bean class="org.apache.ignite.configuration.CacheConfiguration">
          <property name="name" value="KSDATA"/>
          <property name="cacheMode" value="PARTITIONED" />
          <property name="backups" value="2" />
        </bean>
      </list>
    </property>
  </bean>
</beans>

Here is the JDBC client code to connect :

      public void DoConnect() throws ClientException {
            this.IsConnected = false;

            String URL = "jdbc:ignite:thin://" + this.GetNode() + "/" + this.Base + "?user="
+ this.User + "&password=" + this.Password;
            if (this.BShowTraces)
                  System.out.println("[" + URL + "]");

            try {
                  Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
                  this.CX = DriverManager.getConnection(URL);
                  this.CX.setAutoCommit(false);
            } catch (ClassNotFoundException | SQLException e) {
                  e.printStackTrace();
            }
            this.IsConnected = true;
      }

Thanks for your help 😊

Cordialement,

—
NOTE : n/a
—
Gfi Informatique
Philippe Cerou
Architecte & Expert Système
GFI Production / Toulouse
philippe.cerou @gfi.fr
—
1 Rond-point du Général Eisenhower, 31400 Toulouse
Tél. : +33 (0)5.62.85.11.55
Mob. : +33 (0)6.03.56.48.62
www.gfi.world<http://www.gfi.world/>
—
[Facebook]<https://www.facebook.com/gfiinformatique> [Twitter] <https://twitter.com/gfiinformatique>
 [Instagram] <https://www.instagram.com/gfiinformatique/>  [LinkedIn] <https://www.linkedin.com/company/gfi-informatique>
 [YouTube] <https://www.youtube.com/user/GFIinformatique>
—
[cid:image006.jpg@01D2F97F.AA6ABB50]<http://www.gfi.world/>


De : Taras Ledkov [mailto:tledkov@gridgain.com]
Envoyé : jeudi 6 décembre 2018 14:19
À : user@ignite.apache.org
Objet : Re: Sample configuration for one cache [name=KSDATA] and use it with JDBC (client
do not find schema)


Hi,

DB object case sensitivity is the Ignite scourge.

When cache name is used as schema name (the schema doesn't define explicitly for a cache)
the schema name is case sensitive.

In your case you can fix it:
- use schema name "ksdata", e.g. conn.setSchema("\"ksdata\"");
- or rename cache to "KSDATA" (use uppercase in config).
- or use CacheConfiguration#setSqlSchema (please read javadoc [1]).

[1]. https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/CacheConfiguration.html#setSqlSchema-java.lang.String-
06.12.2018 14:06, Philippe CEROU пишет:
Hi all,

I’m new to Ignite and I’ve this problem, I want to reate/declare a simple schema whit
name « KSDATA » in IGNITE XML [default-config.xml].

Here is what I have :

[centos@ip-10-200-2-102 ~]$ cat /opt/app/ignite/2.7.0/config/default-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"<http://www.springframework.org/schema/beans>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<http://www.w3.org/2001/XMLSchema-instance>
xsi:schemaLocation="     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans.xsd">
  <!--
                                Alter configuration below as needed.
                -->
  <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
    <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>10.200.2.102</value><value>10.200.2.105</value><value>10.200.4.103</value><value>10.200.4.106</value><value>10.200.6.101</value><value>10.200.6.104</value>
              </list>
            </property>
          </bean>
        </property>
      </bean>
    </property>
    <property name="dataStorageConfiguration">
      <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
        <property name="defaultDataRegionConfiguration">
          <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
            <property name="persistenceEnabled" value="true"/>
          </bean>
        </property>
      </bean>
    </property>
    <property name="communicationSpi">
      <bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi">
        <property name="localPort" value="4321"/>
      </bean>
    </property>
    <property name="authenticationEnabled" value="true"/>
  </bean>
  <bean id="cache-template-bean" abstract="true" class="org.apache.ignite.configuration.CacheConfiguration">
    <property name="name" value="ksdata"/>
    <property name="cacheMode" value="PARTITIONED" />
    <property name="backups" value="1" />
  </bean>
</beans>

When I use JDBC client (client & server 2.6.0 or 2.7.0) It seems conenct well but any
SQL is not run with following java exception :

...
drop table if exists benchmark
java.sql.SQLException: Failed to set schema for DB connection for thread [schema=KSDATA]
       at org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:750)
       at org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:212)
       at org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:475)
       at com.gfi.rt.lib.database.connectors.jdbc.CxObjJDBC.ExecuteDML(CxObjJDBC.java:238)
       at com.gfi.rt.lib.database.connectors.jdbc.CxObjJDBC.TableDrop(CxObjJDBC.java:659)
       at com.gfi.rt.lib.database.connectors.CxTable.drop(CxTable.java:114)
       at com.gfi.rt.lib.database.connectors.CxTable.drop(CxTable.java:122)
       at com.gfi.rt.bin.database.dbbench.BenchmarkMain.launch(BenchmarkMain.java:248)
       at com.gfi.rt.bin.database.dbbench.BenchmarkMain.<init>(BenchmarkMain.java:100)
       at com.gfi.rt.bin.database.dbbench.BenchmarkMain.main(BenchmarkMain.java:42)
create table benchmark (id NUMERIC(10) primary key,C001 VARCHAR(30),C002 float,C003 float,C004
NUMERIC(10),C005 NUMERIC(10),C006 NUMERIC(10),C007 NUMERIC(10),C008 NUMERIC(10),C009 VARCHAR(30),C010
VARCHAR(30),C011 DATE,C012 VARCHAR(30),C013 VARCHAR(30),C014 VARCHAR(30),C015 NUMERIC(10),C016
float,C017 VARCHAR(30),C018 VARCHAR(30),C019 VARCHAR(30)) WITH "backups=1, affinityKey=id"
java.sql.SQLException: Failed to set schema for DB connection for thread [schema=KSDATA]
       at org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:750)
       at org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:212)
       at org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:475)
       at com.gfi.rt.lib.database.connectors.jdbc.CxObjJDBC.ExecuteDML(CxObjJDBC.java:238)
       at com.gfi.rt.lib.database.connectors.jdbc.CxObjJDBC.TableCreate(CxObjJDBC.java:634)
       at com.gfi.rt.lib.database.connectors.CxTable.create(CxTable.java:63)
       at com.gfi.rt.lib.database.connectors.CxTable.create(CxTable.java:71)
       at com.gfi.rt.bin.database.dbbench.BenchmarkMain.launch(BenchmarkMain.java:269)
       at com.gfi.rt.bin.database.dbbench.BenchmarkMain.<init>(BenchmarkMain.java:100)
       at com.gfi.rt.bin.database.dbbench.BenchmarkMain.main(BenchmarkMain.java:42)
create index benchmarkc001 on benchmark(c001)
java.sql.SQLException: Table doesn't exist: BENCHMARK
       at org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:750)
       at org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:212)
       at org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:475)
       at com.gfi.rt.lib.database.connectors.jdbc.CxObjJDBC.ExecuteDML(CxObjJDBC.java:238)
       at com.gfi.rt.lib.database.connectors.jdbc.CxObjJDBC.TableIndexCreate(CxObjJDBC.java:647)
       at com.gfi.rt.lib.database.connectors.CxTable.addIndex(CxTable.java:81)
       at com.gfi.rt.lib.database.connectors.CxTable.addIndexes(CxTable.java:96)
       at com.gfi.rt.lib.database.connectors.CxTable.addIndexes(CxTable.java:104)
       at com.gfi.rt.bin.database.dbbench.BenchmarkMain.launch(BenchmarkMain.java:270)
       at com.gfi.rt.bin.database.dbbench.BenchmarkMain.<init>(BenchmarkMain.java:100)
       at com.gfi.rt.bin.database.dbbench.BenchmarkMain.main(BenchmarkMain.java:42)
...

And so on ☹

Any full running java JDBC example will be welcome, or best my XML correction 😊

Cordialement,

—
NOTE : n/a
—
Gfi Informatique
Philippe Cerou
Architecte & Expert Système
GFI Production / Toulouse
philippe.cerou @gfi.fr
—
1 Rond-point du Général Eisenhower, 31400 Toulouse
Tél. : +33 (0)5.62.85.11.55
Mob. : +33 (0)6.03.56.48.62
www.gfi.world<http://www.gfi.world/>
—
[Facebook]<https://www.facebook.com/gfiinformatique> [Twitter] <https://twitter.com/gfiinformatique>
 [Instagram] <https://www.instagram.com/gfiinformatique/>  [LinkedIn] <https://www.linkedin.com/company/gfi-informatique>
 [YouTube] <https://www.youtube.com/user/GFIinformatique>
—
[cid:image006.jpg@01D2F97F.AA6ABB50]<http://www.gfi.world/>



--

Taras Ledkov

Mail-To: tledkov@gridgain.com<mailto:tledkov@gridgain.com>
Mime
View raw message