Discussion:
Getting error while inserting data in cassandra table using Java with JDBC
himanshu.joshi
2013-04-17 13:31:03 UTC
Permalink
Hi,


When I am trying to insert the data into a table using Java with JDBC, I
am getting the error

InvalidRequestException(why:cannot parse 'Jo' as hex bytes)

My insert quarry is:
insert into temp(id,name,value,url_id) VALUES(108, 'Aa','Jo',10);

This insert quarry is running successfully from CQLSH command prompt but
not from the code

The quarry I have used to create the table in CQLSH is:

CREATE TABLE temp (
id bigint PRIMARY KEY,
dt_stamp timestamp,
name text,
url_id bigint,
value text
) WITH
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};



I guess the problem may because of undefined
key_validation_class,default_validation_class and comparator etc.
Is there any way to define these attributes using CQLSH ?
I have already tried ASSUME command but it also have not resolved the
problem.

I am a beginner in cassandra and need your guidance.
--
Thanks & Regards,
Himanshu Joshi
aaron morton
2013-04-17 18:36:52 UTC
Permalink
What version are you using ?
And what JDBC driver ?

Sounds like the driver is not converting the value to bytes for you.
I guess the problem may because of undefined key_validation_class,default_validation_class and comparator etc.
If you are using CQL these are not relevant.

Cheers

-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand

@aaronmorton
http://www.thelastpickle.com
Hi,
When I am trying to insert the data into a table using Java with JDBC, I am getting the error
InvalidRequestException(why:cannot parse 'Jo' as hex bytes)
insert into temp(id,name,value,url_id) VALUES(108, 'Aa','Jo',10);
This insert quarry is running successfully from CQLSH command prompt but not from the code
CREATE TABLE temp (
id bigint PRIMARY KEY,
dt_stamp timestamp,
name text,
url_id bigint,
value text
) WITH
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};
I guess the problem may because of undefined key_validation_class,default_validation_class and comparator etc.
Is there any way to define these attributes using CQLSH ?
I have already tried ASSUME command but it also have not resolved the problem.
I am a beginner in cassandra and need your guidance.
--
Thanks & Regards,
Himanshu Joshi
himanshu.joshi
2013-04-18 05:24:42 UTC
Permalink
Post by aaron morton
What version are you using ?
And what JDBC driver ?
Sounds like the driver is not converting the value to bytes for you.
Post by himanshu.joshi
I guess the problem may because of undefined
key_validation_class,default_validation_class and comparator etc.
If you are using CQL these are not relevant.
Cheers
-----------------
Aaron Morton
Freelance Cassandra Consultant
New Zealand
@aaronmorton
http://www.thelastpickle.com
Post by himanshu.joshi
Hi,
When I am trying to insert the data into a table using Java with
JDBC, I am getting the error
InvalidRequestException(why:cannot parse 'Jo' as hex bytes)
insert into temp(id,name,value,url_id) VALUES(108, 'Aa','Jo',10);
This insert quarry is running successfully from CQLSH command prompt
but not from the code
CREATE TABLE temp (
id bigint PRIMARY KEY,
dt_stamp timestamp,
name text,
url_id bigint,
value text
) WITH
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};
I guess the problem may because of undefined
key_validation_class,default_validation_class and comparator etc.
Is there any way to define these attributes using CQLSH ?
I have already tried ASSUME command but it also have not resolved the problem.
I am a beginner in cassandra and need your guidance.
--
Thanks & Regards,
Himanshu Joshi
Hi Aaron,

The problem is resolved now as I upgraded the version of JDBC to 1.2.2
Earlier I was using JDBC version 1.1.6 with Cassandra 1.2.2

Thanks for your guidance.
--
Thanks & Regards,
Himanshu Joshi
Loading...