我使用hivejdbc连接在hive中插入数据(我知道单记录插入不好)。但是当我使用preparedstatement的setblob()方法时,它说方法不存在。
在java中,是否有其他方法可以按语法将blob数据插入到配置单元中。
code:-
File ImgPath = new File("C:\\Users\\ezswapr\\IdeaProjects\\DataStructure\\org.priyaranjan.ds\\src\\output\\"+"Desert.jpg");
FileInputStream fileinput = new FileInputStream(ImgPath);
System.out.println("length of the file is :" + (int)ImgPath.length());
String query = "INSERT INTO image(data) VALUES(?);";
Statement stmt = hiveconnection.createStatement();
//stmt.executeQuery("INSERT INTO image(data) VALUES(?);");
PreparedStatement p = hiveconnection.prepareStatement(query);
byte[] bytearray = IOUtils.toByteArray(fileinput);
Blob blob = new javax.sql.rowset.serial.SerialBlob(bytearray);
p.setBlob(1,blob);
p.execute();
System.out.println("Closing the connections");
hiveconnection.close();
error:-
log4j:WARN No appenders could be found for logger (org.apache.hive.jdbc.Utils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
length of the file is :845941
Exception in thread "main" java.sql.SQLException: Method not supported
at org.apache.hive.jdbc.HivePreparedStatement.setBlob(HivePreparedStatement.java:305)
at treeJava.Smpblobhive.main(Smpblobhive.java:69)
Process finished with exit code 1
暂无答案!
目前还没有任何答案,快来回答吧!