Java DataStax Cassandra异常错误

时间:2018-04-05 21:53:44

标签: java cassandra cassandra-3.0

我在java中插入时遇到此错误。有没有办法准备 插入驱动程序错误?

错误:

  

线程中的异常" main" com.datastax.driver.core.exceptions.InvalidQueryException:预期4或0字节int(10)

List<Flight> flightList = ProcessFlightsCSV.processFlights("flights_from_pg.csv");

for (Flight flight : flightList) {

    System.out.println(flight);

    Insert query = QueryBuilder.insertInto("flights")
            .value("id", flight.getId())
            .value("year", flight.getYear())
            .value("fl_date", flight.getFlDate())
            .value("airline_id", flight.getAirlineId())
            .value("carrier", flight.getCarrier())
            .value("fl_num", flight.getFlNum())
            .value("origin_airport_id", flight.getOriginAirportId())
            .value("origin", flight.getOrigin())
            .value("origin_city_name", flight.getOriginCityName())
            .value("origin_state_abr", flight.getOriginStateAbr())
            .value("dest", flight.getDest())
            .value("day_of_month", flight.getDayOfMonth())
            .value("dest_city_name", flight.getDestCityName())
            .value("dest_state_abr", flight.getDestStateAbr())
            .value("dep_time", flight.getDepTime())
            .value("arr_time", flight.getArrTime())
            .value("distance", flight.getDistance());

    session.execute(query);

}

1 个答案:

答案 0 :(得分:0)

  1. 希望您在执行此查询之前有适当的会话。
  2. 更新您的session.execute(query.toString());