Hi Philippe,

The Date data type is new in Cassandra 2.2 and thus you'll have to use the
latest DevCenter (1.4, which I think you are already using) and Java driver
(2.2RC3).

You'll find some details about using these new types in this blog post
http://www.datastax.com/dev/blog/datastax-java-driver-2-2-0-rc1-released,
but
make sure you also check the Changelog
https://github.com/datastax/java-driver/tree/2.2/changelog as for example
the DateWithoutTime has been renamed to LocalDate.

hth

On Fri, Aug 21, 2015 at 4:57 AM, Philippe Suray <
philippe.su...@market-ip.com> wrote:

> Hello,
>
>
>
> I have recently installed Datastax-Cassandra-2.2.0 on a Debian system.
>
> I successfully started Cassandra.
>
>
>
> In order to test it, I have written a small client in Java that use
> cassandra-driver-core-2.1.7.1.jar from Datastax.
>
> I also installed the DevCenter in order to create a keyspace and a table.
> Here is the generated CQL
>
>
>
> CREATE KEYSPACE IF NOT EXISTS* test*
>
> WITH REPLICATION = {
>
>        'class' : 'NetworkTopologyStrategy',
>
>        'datacenter1' : 3
>
> };
>
> CREATE TABLE IF NOT EXISTS* test*.*incoming_message* (
>
> *       id* uuid,
>
> *       device_id* text,
>
> *       creation_date* date,
>
> *       event_timestamp* timestamp,
>
> *       raw_message* text,
>
>        PRIMARY KEY ((*device_id*,* creation_date* ),* event_timestamp*)
>
> ) WITH CLUSTERING ORDER BY (*event_timestamp* DESC);
>
>
>
>
>
> Based on this http://cassandra.apache.org/doc/cql3/CQL-2.2.html#usingdates,
> I used ‘date’ type to define a column ‘creation_date’ for
> ‘incoming_message’ table
>
> I tried to insert data in the table with this code:
>
> Insert insert = QueryBuilder.*insertInto*("incoming_message")
>
>                         .*value*("id", UUIDs.*random*())
>
>                         .*value*("device_id", celloMessage.*getUnitID*())
>
>                         .*value*("creation_date", SimpleDateSerializer.
> *timeInMillisToDay*(DateTime.*now*(DateTimeZone.*UTC*).*getMillis*()))
>
>                         .*value*("event_timestamp", DateTime.*now*(
> DateTimeZone.*UTC*).*getMillis*())
>
>                         .*value*("raw_message", Hex.*encodeHexString*(
> celloMessage.*getMessage*()));
>
>
>
> I use a helper class SimpleDateSerializer in order to format the date.
> This class can be found in Cassandra-clientutil-2.2.0.jar
>
> When I try to insert records, I have this stack:
>
> Caused by: *com.datastax.driver.core.exceptions.InvalidQueryException*:
> Unable to make unsigned int (for date) from: '-2147466980'
>
>        at com.datastax.driver.core.Responses$Error.asException(
> *Responses.java:102*)
>
>        at com.datastax.driver.core.DefaultResultSetFuture.onSet(
> *DefaultResultSetFuture.java:118*)
>
>        at com.datastax.driver.core.RequestHandler.setFinalResult(
> *RequestHandler.java:183*)
>
>        at com.datastax.driver.core.RequestHandler.access$2300(
> *RequestHandler.java:45*)
>
>        at
> com.datastax.driver.core.RequestHandler$SpeculativeExecution.setFinalResult(
> *RequestHandler.java:748*)
>
>        at
> com.datastax.driver.core.RequestHandler$SpeculativeExecution.onSet(
> *RequestHandler.java:573*)
>
>        at com.datastax.driver.core.Connection$Dispatcher.channelRead0(
> *Connection.java:991*)
>
>        at com.datastax.driver.core.Connection$Dispatcher.channelRead0(
> *Connection.java:913*)
>
>        at io.netty.channel.SimpleChannelInboundHandler.channelRead(
> *SimpleChannelInboundHandler.java:105*)
>
>        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(
> *AbstractChannelHandlerContext.java:308*)
>
>        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(
> *AbstractChannelHandlerContext.java:294*)
>
>        at io.netty.handler.timeout.IdleStateHandler.channelRead(
> *IdleStateHandler.java:254*)
>
>        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(
> *AbstractChannelHandlerContext.java:308*)
>
>        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(
> *AbstractChannelHandlerContext.java:294*)
>
>        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(
> *MessageToMessageDecoder.java:103*)
>
>        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(
> *AbstractChannelHandlerContext.java:308*)
>
>        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(
> *AbstractChannelHandlerContext.java:294*)
>
>        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(
> *ByteToMessageDecoder.java:244*)
>
>        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(
> *AbstractChannelHandlerContext.java:308*)
>
>        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(
> *AbstractChannelHandlerContext.java:294*)
>
>        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(
> *DefaultChannelPipeline.java:846*)
>
>        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(
> *AbstractNioByteChannel.java:131*)
>
>        at io.netty.channel.nio.NioEventLoop.processSelectedKey(
> *NioEventLoop.java:511*)
>
>        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(
> *NioEventLoop.java:468*)
>
>        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(
> *NioEventLoop.java:382*)
>
>        at io.netty.channel.nio.NioEventLoop.run(*NioEventLoop.java:354*)
>
>        ... 2 more
>
>
>
> What Am I doing wrong?
>
>
>
> Thank you for your help.
>
>
>
> Regards
>
>
>
> Philippe SURAY
>



-- 
Bests,

Alex Popescu | @al3xandru
Sen. Product Manager @ DataStax


<http://cassandrasummit-datastax.com/?utm_campaign=summit15&utm_medium=summiticon&utm_source=emailsignature>

Reply via email to