I have encountered two different kinds of InvalidRequestExceptions while i was working with Cassandra database and Java and I could not find help online.
Fortunately, I could resolve these myself. They are:
Fortunately, I could resolve these myself. They are:
- InvalidRequestException(why:unconfigured columnfamily sample)
This Exception is encountered if the given column family name is not created in the database. The column family means table in relational database. There are two ways to solve this problem.
- In java code, you can change the name of the column family to the one existing in the database.
Eg: If the code is like this,
mutator.insert("sample", "auth", HFactory.createStringColumn("username", "admin"));
Change the column family name sample to the one present in the database i.e., if the column family name is login then it should be,
mutator.insert("login", "auth", HFactory.createStringColumn("username", "admin"));
- Create a column family name in the database as follows,
Eg: create column family login ;
- InvalidRequestException(why:Keyspace Sample does not exist)
This Exception is encountered if the given Keyspace name is not created in the database. The keyspace means database in relational database. There are two ways to solve this problem.
- In java code, you can change the name of the Keyspace to the one existing in the database.
Eg: If the code is like this,
Keyspace keyspace = HFactory.createKeyspace("Sample", cluster);
Change the column family name sample to the one present in the database i.e., if the Keyspace name is Login then it should be,
Keyspace keyspace = HFactory.createKeyspace("Login", cluster);
- Create a keyspace in the database as follows,
Eg: create keyspace login ;
No comments:
Post a Comment