如果复制不起作用,如何将数据从csv文件导入cassandra…复制错误

zlhcx6iw  于 2021-08-25  发布在  Java
关注(0)|答案(0)|浏览(225)

我试图从csv文件导入数据,但出现以下错误:-原因:com.datasax.driver.core.exceptions.syntaxerror:line1:0输入“copy”([copy]…)处的可行替代方案
我的代码是:

import com.datastax.driver.core.*;

//import java.io.BufferedReader;
//import java.io.FileReader;
//import java.io.IOException;
//import org.apache.commons.lang.StringUtils;

public class Test {

    private static Session getSession(String[] contactPoints) {
        Cluster cluster = Cluster.builder()
            // Initial set of nodes to connect to.  All nodes do not need to be
            // specified.  The cassandra driver will self discover other nodes
            // in the cluster, so you just need to specify an initial handful.
            .addContactPoints(contactPoints)
            .withCredentials("testclust0011_rw", "SqecXzR8")
            .withSSL() // remove if SSL is not enabled
            .build();

    return cluster.connect("testclust0011");
    // You're connected! Do work here...

}

   public static void main(String[] args) {
      //String serverIp = "169.125.178.237";
      //String keyspace = "testclust0011";

    String [] contactPoints = new String []{"169.125.178.237","169.99.199.36","169.125.176.196","169.99.198.228","169.91.232.142","169.99.199.19"};
    Session session = getSession(contactPoints);

   // String cqlStatement = "SELECT * FROM emp";

  //  String cql = "CREATE TABLE testclust0011.PrAudit(eventTypeId int PRIMARY 
     KEY,prinId int,requestorId int,eventSpec text)";
  //  session.execute(cql);
 // String  cql = "INSERT INTO PrAudit(eventTypeId,prinId,requestorId,eventSpec) 
   VALUES(1,2,3,'password')";
  //   session.execute(cql);
   for (Row row : session.execute(cqlStatement)) {
        System.out.println(row.toString());
    }

    String ss = "COPY PrAudit " +
            "from 'c://Users//V786612//sales.csv' ";
      session.execute(ss);
    session.close();
   }

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题