gpt4 book ai didi

nosql - cassandra CQL3-Hex Bytes 转换错误的插入错误

转载 作者:行者123 更新时间:2023-12-01 05:23:45 24 4
gpt4 key购买 nike

当我使用 cassandra -jdbc 将数据惰性化到表中时,出现错误 java.sql.SQLSyntaxErrorException: cannot parse 'ani' as hex bytes

在 localhost:9160 连接到测试集群。
[cqlsh 2.3.0 | Cassandra 1.2.0 | CQL 规范 3.0.0 |节俭协议(protocol) 19.35.0]
使用 CQL3 创建表

cqlsh:testkeyspace> create columnfamily login(
... key varchar primary key,
... name varchar,
... password varchar);


package com.bsmart;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class InsertCass {

public static void main(String[] args) {
try
{
Class.forName("org.apache.cassandra.cql.jdbc.CassandraDriver");
Connection con =DriverManager.getConnection("jdbc:cassandra://localhost:9160/testkeyspace");

String qry = "INSERT INTO login (KEY, name, password) VALUES ( 't', 'ani','agrawal');";
PreparedStatement smt = con.prepareStatement(qry);
smt.execute();
// int i=smt.executeUpdate();

System.out.println("records inserted>>>>");



}
catch(Exception e)
{
System.out.println(" error: "+e.getMessage());
e.printStackTrace();
}

}

但是错误-
log4j:WARN No appenders could be found for logger (org.apache.cassandra.cql.jdbc.CassandraDriver).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
java.sql.SQLSyntaxErrorException: cannot parse 'ani' as hex bytes
at org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.doExecute(CassandraPreparedStatement.java:155)
at org.apache.cassandra.cql.jdbc.CassandraPreparedStatement.execute(CassandraPreparedStatement.java:191)
at com.bsmart.InsertCass.main(InsertCass.java:18)
error: cannot parse 'ani' as hex bytes

请帮我。
谢谢

最佳答案

您需要创建 name列为 textvarchar .您收到的错误表明它被创建为 blob .

关于nosql - cassandra CQL3-Hex Bytes 转换错误的插入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15022143/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com