我们之前的MySQL驱动是6.0.6的,现在升级到8.0.11后,别的问题没有,就在插入大量数据时出现了问题,我们使用的是load datalocal infile插入的;
以下是出现问题的代码:
try {
if(inputStream == null){
logger.info("InputStream is null ,No data is imported");
return 0;
}
conn = jdbcTemplate.getDataSource().getConnection();
statement = conn.prepareStatement(sql);
if (statement.isWrapperFor(Statement.class)) {
com.mysql.cj.jdbc.ServerPreparedStatement mysqlStatement = statement.unwrap(com.mysql.cj.jdbc.ServerPreparedStatement.class);
mysqlStatement.setLocalInfileInputStream(inputStream);
result = mysqlStatement.executeUpdate();
}
return result;
} catch (Exception e) {
logger.info("批量插入eda数据异常,原因: " + e.getMessage());
}
这个是出现的报错信息:
批量插入eda数据异常,原因: Unable to unwrap to class com.mysql.cj.jdbc.ServerPreparedStatement
查了好久都没有找到解决办法,各位大神帮忙啊,感激不尽