Created on 06-10-2022 01:37 AM - edited 06-10-2022 02:35 AM
the table DDL as :
create table mid.user_info(id int,name string,address string,email string,insert_time timestamp,primary key(id)) partition by hash(id) partitions 6 stored as kudu;
my java code such as:
import java.sql.*;
import java.time.LocalDateTime;
public class test {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("com.cloudera.impala.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:impala://impala.db.com:8006/mid;AuthMech=0;UseNativeQuery=1;", "impala", "impala");
String sql = "upsert into user_info(id, name, address, email, insert_time) values (?,?,?,?,?)";
PreparedStatement statement = conn.prepareStatement(sql);
statement.setInt(1,106);
statement.setString(2, "张三");
statement.setString(3, "上海");
statement.setString(4, "John@xyz.com");
statement.setTimestamp(5, Timestamp.valueOf(LocalDateTime.now()));
statement.addBatch();
statement.executeBatch();
statement.close();
conn.close();
}
}
I get a bad result when I execute it,The Chinese string appears to be truncated:
How can I solve this problem?
please!
Created 06-12-2022 05:57 PM
hi @ShankerSharma ,How can I solve this problem?
Created 06-26-2022 06:16 PM
As upsert is not SQL-92 syntax, the Impala JDBC driver does not currently support it. However, we are currently testing a newer version of the JDBC driver and hope to support upsert in the near future. For the time being, please break these statements into a combination of insert and update statements.
Created 11-15-2022 10:31 PM
This is not the essence of the problem, what the question actually wants to ask is the problem of inserting data with Impala JDBC, Chinese strings being truncated and garbled.