Hi igniters!
I have created a table using JDBC. And I would like to fill it with data
using data streamer. But after that I can't execute sql query and get data.
After some experimentation, it turned out that SQL select does not return
the data put in the table using the cache API.
@Test
public void differentApproachToCreateTableTest() throws Exception {
final String TABLE_NAME = "SqlTable";
try (Ignite ignored = Ignition.start(Config.getServerConfiguration());
IgniteClient client = Ignition.startClient(
new ClientConfiguration()
.setBinaryConfiguration(
new
BinaryConfiguration().setCompactFooter(true)
)
.setAddresses(Config.SERVER))
) {
// Creating a table using JDBC.
try (Connection conn =
DriverManager.getConnection("jdbc:ignite:thin://localhost:10800/PUBLIC")) {
conn.prepareStatement("CREATE TABLE IF NOT EXISTS SqlTable (id
int, name varchar, PRIMARY KEY (id)) " +
"WITH
\"atomicity=transactional,template=partitioned,CACHE_NAME=SqlTable\"")
.execute();
} catch (SQLException ex) {
ex.printStackTrace();
}
final ClientCache<Integer, String> cache = client.cache(TABLE_NAME);
cache.put(5, "value of column name field 5");
assertEquals(1, cache.size());
assertEquals("value of column name field 5", cache.get(5));
// No record is visible to SQL.
assertEquals(1,
cache.query(new SqlFieldsQuery("select count(*) from " +
TABLE_NAME )).getAll().get(0).get(0));
}
}
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/