fix: 创建MySQL数据源时出现 Public Key Retrieval is not allowed错误

This commit is contained in:
taojinlong 2021-09-28 18:48:15 +08:00
parent acc28ccd39
commit 2dcae3d146
3 changed files with 27 additions and 13 deletions

View File

@ -1,6 +1,7 @@
package io.dataease.commons.utils;
import com.google.gson.Gson;
import io.dataease.datasource.dto.TableFiled;
import org.apache.poi.hssf.usermodel.HSSFCell;
import java.io.FileInputStream;
import java.io.InputStream;
@ -56,8 +57,9 @@ public class ExcelReaderUtil {
} else if (fileName.endsWith(EXCEL07_EXTENSION)) {//处理excel2007文件
ExcelXlsxReader excelXlsxReader = new ExcelXlsxReader();
excelXlsxReader.process(inputStream);
System.out.println(excelXlsxReader.totalSheets.size());
System.out.println(excelXlsxReader.totalSheets.get(0).getExcelLable());
System.out.println(excelXlsxReader.totalSheets.get(0).getFields().size());
for (TableFiled field : excelXlsxReader.totalSheets.get(0).getFields()) {
System.out.println(new Gson().toJson(field));
}
@ -68,8 +70,10 @@ public class ExcelReaderUtil {
}
}
/* public static void main(String[] args) throws Exception {
String file ="Metersphere_case_DataEase功能用例.xlsx";
public static void main(String[] args) throws Exception {
String file ="各省市GDP-表格_加内容.xlsx";
ExcelReaderUtil.readExcel(file, new FileInputStream("/Users/taojinlong/Desktop/" + file));
} */
}
}

View File

@ -234,7 +234,7 @@ public class ExcelXlsxReader extends DefaultHandler {
return;
}
//t元素也包含字符串
if (isTElement) {//这个程序没经过
if (isTElement) { //这个程序没经过
//将单元格内容加入rowlist中在这之前先去掉字符串前后的空白符
String value = lastIndex.trim();
if(curRow==1){
@ -271,6 +271,9 @@ public class ExcelXlsxReader extends DefaultHandler {
for (int i = 0; i < len; i++) {
if(curCol < this.fields.size()){
cellList.add(curCol, "");
if(curRow==1){
addField("", curCol);
}
curCol++;
}
}
@ -413,12 +416,7 @@ public class ExcelXlsxReader extends DefaultHandler {
break;
}
if(curRow==1){
TableFiled tableFiled = new TableFiled();
tableFiled.setFieldType("TEXT");
tableFiled.setFieldSize(65533);
tableFiled.setFieldName(thisStr);
tableFiled.setRemarks(thisStr);
this.fields.add(tableFiled);
addField(thisStr, null);
}else {
if(CollectionUtils.isEmpty(this.getFields())){
throw new RuntimeException(Translator.get("i18n_excel_header_empty"));
@ -443,6 +441,18 @@ public class ExcelXlsxReader extends DefaultHandler {
return thisStr;
}
private void addField(String columeName, Integer index){
TableFiled tableFiled = new TableFiled();
tableFiled.setFieldType("TEXT");
tableFiled.setFieldSize(65533);
tableFiled.setFieldName(columeName);
tableFiled.setRemarks(columeName);
if(index != null){
this.fields.add(index, tableFiled);
}else {
this.fields.add(tableFiled);
}
}
private String getType(String thisStr){
if(totalRows==0){
return "TEXT";

View File

@ -11,7 +11,7 @@ public class MysqlConfigration extends JdbcDTO {
public String getJdbc() {
// 连接参数先写死后边要把编码时区等参数放到数据源的设置中
return "jdbc:mysql://HOSTNAME:PORT/DATABASE?characterEncoding=UTF-8&connectTimeout=5000&useSSL=false"
return "jdbc:mysql://HOSTNAME:PORT/DATABASE?characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true"
.replace("HOSTNAME", getHost().trim())
.replace("PORT", getPort().toString().trim())
.replace("DATABASE", getDataBase().trim());