Przeglądaj źródła

德阳漏洞升级mysql8.0

xiexh 5 miesięcy temu
rodzic
commit
71f3ec378a

+ 6 - 6
ibps-base-root/modules/base-db/src/main/java/com/lc/ibps/base/db/exception/spi/SpiExceptionServicePersistenceException.java

@@ -5,8 +5,8 @@ import java.lang.reflect.InvocationTargetException;
 import org.apache.ibatis.exceptions.PersistenceException;
 
 import com.lc.ibps.base.core.exception.spi.AbstractSpiExceptionService;
-import com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException;
-
+//import com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException;
+import java.sql.SQLIntegrityConstraintViolationException;
 import cn.hutool.core.util.ReUtil;
 
 /** 
@@ -66,8 +66,8 @@ public class SpiExceptionServicePersistenceException extends AbstractSpiExceptio
 			// "Table 'ibps_test_v2.8.10.t_zdyzb' doesn't exist"
 			InvocationTargetException itEx = (InvocationTargetException) mysqlseeCause;
 			Throwable te = itEx.getTargetException();
-			if(te instanceof MySQLSyntaxErrorException) {
-				MySQLSyntaxErrorException mysqlsee = (MySQLSyntaxErrorException) te;
+			if(te instanceof SQLIntegrityConstraintViolationException) {
+				SQLIntegrityConstraintViolationException mysqlsee = (SQLIntegrityConstraintViolationException) te;
 				int code = mysqlsee.getErrorCode();
 				if(1146 == code) {
 					error = mysqlsee.getMessage();
@@ -118,8 +118,8 @@ public class SpiExceptionServicePersistenceException extends AbstractSpiExceptio
 			// "Table 'ibps_test_v2.8.10.t_zdyzb' doesn't exist"
 			InvocationTargetException itEx = (InvocationTargetException) mysqlseeCause;
 			Throwable te = itEx.getTargetException();
-			if(te instanceof MySQLSyntaxErrorException) {
-				MySQLSyntaxErrorException mysqlsee = (MySQLSyntaxErrorException) te;
+			if(te instanceof SQLIntegrityConstraintViolationException) {
+				SQLIntegrityConstraintViolationException mysqlsee = (SQLIntegrityConstraintViolationException) te;
 				int code = mysqlsee.getErrorCode();
 				if(1146 == code) {
 					error = mysqlsee.getMessage();

+ 5 - 5
ibps-base-root/modules/base-framework-ddd/src/main/java/com/lc/ibps/base/framework/exception/spi/mysql/SpiExceptionServiceJdbc4MySQLIntegrityConstraintViolationException.java

@@ -4,8 +4,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.lc.ibps.base.core.exception.spi.AbstractSpiExceptionService;
-import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException;
-
+//import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException;
+import java.sql.SQLIntegrityConstraintViolationException;
 import cn.hutool.core.util.ReUtil;
 
 /** 
@@ -31,13 +31,13 @@ public class SpiExceptionServiceJdbc4MySQLIntegrityConstraintViolationException
 	
 	@Override
 	public String getClassName() {
-		return MySQLIntegrityConstraintViolationException.class.getName();
+		return SQLIntegrityConstraintViolationException.class.getName();
 	}
 	
 	@Override
 	public String doAnalysis(Exception exception) {
 		StringBuilder message = new StringBuilder();
-		MySQLIntegrityConstraintViolationException cause = (MySQLIntegrityConstraintViolationException) exception;
+		SQLIntegrityConstraintViolationException cause = (SQLIntegrityConstraintViolationException) exception;
 		
 		int errorCode = cause.getErrorCode();
 		String state = cause.getSQLState();
@@ -60,7 +60,7 @@ public class SpiExceptionServiceJdbc4MySQLIntegrityConstraintViolationException
 	@Override
 	public String doAnalysis(Throwable throwable) {
 		StringBuilder message = new StringBuilder();
-		MySQLIntegrityConstraintViolationException cause = (MySQLIntegrityConstraintViolationException) throwable;
+		SQLIntegrityConstraintViolationException cause = (SQLIntegrityConstraintViolationException) throwable;
 		
 		int errorCode = cause.getErrorCode();
 		String state = cause.getSQLState();

+ 5 - 5
ibps-base-root/modules/base-framework-ddd/src/main/java/com/lc/ibps/base/framework/exception/spi/mysql/SpiExceptionServiceMySQLIntegrityConstraintViolationException.java

@@ -4,8 +4,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.lc.ibps.base.core.exception.spi.AbstractSpiExceptionService;
-import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException;
-
+//import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException;
+import java.sql.SQLIntegrityConstraintViolationException;
 import cn.hutool.core.util.ReUtil;
 
 /** 
@@ -30,13 +30,13 @@ public class SpiExceptionServiceMySQLIntegrityConstraintViolationException exten
 	
 	@Override
 	public String getClassName() {
-		return MySQLIntegrityConstraintViolationException.class.getName();
+		return SQLIntegrityConstraintViolationException.class.getName();
 	}
 	
 	@Override
 	public String doAnalysis(Exception exception) {
 		StringBuilder message = new StringBuilder();
-		MySQLIntegrityConstraintViolationException cause = (MySQLIntegrityConstraintViolationException) exception;
+		SQLIntegrityConstraintViolationException cause = (SQLIntegrityConstraintViolationException) exception;
 		
 		int errorCode = cause.getErrorCode();
 		String state = cause.getSQLState();
@@ -59,7 +59,7 @@ public class SpiExceptionServiceMySQLIntegrityConstraintViolationException exten
 	@Override
 	public String doAnalysis(Throwable throwable) {
 		StringBuilder message = new StringBuilder();
-		MySQLIntegrityConstraintViolationException cause = (MySQLIntegrityConstraintViolationException) throwable;
+		SQLIntegrityConstraintViolationException cause = (SQLIntegrityConstraintViolationException) throwable;
 		
 		int errorCode = cause.getErrorCode();
 		String state = cause.getSQLState();

+ 5 - 5
ibps-base-root/modules/base-framework-ddd/src/main/java/com/lc/ibps/base/framework/exception/spi/mysql/SpiExceptionServiceMysqlDataTruncation.java

@@ -4,8 +4,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.lc.ibps.base.core.exception.spi.AbstractSpiExceptionService;
-import com.mysql.jdbc.MysqlDataTruncation;
-
+//import com.mysql.jdbc.MysqlDataTruncation;
+import java.sql.DataTruncation;
 import cn.hutool.core.util.ReUtil;
 
 /** 
@@ -29,13 +29,13 @@ public class SpiExceptionServiceMysqlDataTruncation extends AbstractSpiException
 	
 	@Override
 	public String getClassName() {
-		return MysqlDataTruncation.class.getName();
+		return DataTruncation .class.getName();
 	}
 	
 	@Override
 	public String doAnalysis(Exception exception) {
 		StringBuilder message = new StringBuilder();
-		MysqlDataTruncation cause = (MysqlDataTruncation) exception;
+		DataTruncation  cause = (DataTruncation ) exception;
 		
 		int errorCode = cause.getErrorCode();
 		String state = cause.getSQLState();
@@ -58,7 +58,7 @@ public class SpiExceptionServiceMysqlDataTruncation extends AbstractSpiException
 	@Override
 	public String doAnalysis(Throwable throwable) {
 		StringBuilder message = new StringBuilder();
-		MysqlDataTruncation cause = (MysqlDataTruncation) throwable;
+		DataTruncation  cause = (DataTruncation ) throwable;
 		
 		int errorCode = cause.getErrorCode();
 		String state = cause.getSQLState();

+ 1 - 0
ibps-oauth-root/modules/oauth-server2/pom.xml

@@ -107,6 +107,7 @@
 		<dependency>
 			<groupId>mysql</groupId>
 			<artifactId>mysql-connector-java</artifactId>
+			<version>8.0.28</version>
 		</dependency>
 		<dependency>
 		    <groupId>com.microsoft.sqlserver</groupId>

+ 2 - 2
ibps-oauth-root/modules/oauth-server2/src/main/resources/conf/dataSource-dev.xml

@@ -6,11 +6,11 @@
 
  	<!-- dev下使用该链接 -->
  	<dbType>mysql</dbType>
-  	<driver>com.mysql.jdbc.Driver</driver>
+  	<driver>com.mysql.cj.jdbc.Driver</driver>
 <!--    <driverUrl>jdbc:mysql://39.108.0.125:3306/klims-ibps?useUnicode=true&amp;characterEncoding=utf-8</driverUrl>-->
 <!--    <user>root</user>-->
 <!--    <password>!$%^QWER</password>-->
-    <driverUrl>jdbc:mysql://192.168.2.161:3306/klims-ibps3?useUnicode=true&amp;characterEncoding=utf-8</driverUrl>
+    <driverUrl>jdbc:mysql://192.168.2.192:3306/klims-ibps3?useUnicode=true&amp;characterEncoding=utf-8&amp;allowMultiQueries=true&amp;useSSL=false&amp;allowPublicKeyRetrieval=true&amp;defaultAuthenticationPlugin=mysql_native_password&amp;serverTimezone=Asia/Shanghai</driverUrl>
     <user>root</user>
     <password>test001</password>
 	<!-- 	

+ 1 - 0
ibps-provider-root/modules/provider-business/pom.xml

@@ -224,6 +224,7 @@
 		<dependency>
 			<groupId>mysql</groupId>
 			<artifactId>mysql-connector-java</artifactId>
+			<version>8.0.28</version>
 		</dependency>
 		<dependency>
 			<groupId>com.microsoft.sqlserver</groupId>

+ 2 - 2
ibps-provider-root/modules/provider-business/src/main/resources/conf/dataSource-dev.xml

@@ -6,8 +6,8 @@
 
     <!-- dev下使用该链接 -->
     <dbType>mysql</dbType>
-    <driver>com.mysql.jdbc.Driver</driver>
-    <driverUrl>jdbc:mysql://192.168.2.161:3306/klims-ibps3?useUnicode=true&amp;characterEncoding=utf-8</driverUrl>
+    <driver>com.mysql.cj.jdbc.Driver</driver>
+    <driverUrl>jdbc:mysql://192.168.2.192:3306/klims-ibps3?useUnicode=true&amp;characterEncoding=utf-8&amp;allowMultiQueries=true&amp;useSSL=false&amp;allowPublicKeyRetrieval=true&amp;defaultAuthenticationPlugin=mysql_native_password&amp;serverTimezone=Asia/Shanghai</driverUrl>
     <user>root</user>
     <password>test001</password>
 

+ 1 - 0
ibps-provider-root/modules/provider-platform/pom.xml

@@ -82,6 +82,7 @@
 		<dependency>
 			<groupId>mysql</groupId>
 			<artifactId>mysql-connector-java</artifactId>
+			<version>8.0.28</version>
 		</dependency>
 		<dependency>
 		    <groupId>com.microsoft.sqlserver</groupId>

+ 69 - 0
ibps-provider-root/modules/provider-platform/src/main/java/com/lc/ibps/platform/util/BusiUtils.java

@@ -0,0 +1,69 @@
+package com.lc.ibps.platform.util;
+
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+public final class BusiUtils {
+	private BusiUtils(){
+		throw new UnsupportedOperationException("工具类不允许实例化");
+	}
+	/**
+	 * 将周期字符串转换为月份数 12个月,1年,半年,6月分别返回12,12,6,6
+	 * 空字符,null,无法解析的返回-1
+	 * @param Str 周期字符串
+	 * @return 月份数
+	 */
+	public static int parseZhouQiToMonths(Object Str) {
+		if (Str == null || Str.toString().trim().isEmpty()) {
+			return -1;
+		}
+
+		String zhouQi = Str.toString().trim();
+
+		// 1. 首先尝试解析纯数字
+		if (isPureNumber(zhouQi)) {
+			return Integer.parseInt(zhouQi);
+		}
+
+		// 2. 处理特殊中文周期描述
+		if ("一年".equals(zhouQi)) {
+			return 12;
+		}
+		if ("半年".equals(zhouQi)) {
+			return 6;
+		}
+		if ("六个月".equals(zhouQi)) {
+			return 6;
+		}
+		if ("十二个月".equals(zhouQi)) {
+			return 12;
+		}
+		// 3. 使用正则表达式提取数字部分
+		Pattern pattern = Pattern.compile("(\\d+)");
+		Matcher matcher = pattern.matcher(zhouQi);
+
+		if (matcher.find()) {
+			String numberStr = matcher.group(1);
+			return Integer.parseInt(numberStr);
+		}
+        return -1;//无法解析周期字符串
+	}
+
+	/**
+	 * 检查字符串是否为纯数字
+	 */
+	private static boolean isPureNumber(String str) {
+		if (str == null || str.isEmpty()) {
+			return false;
+		}
+		for (char c : str.toCharArray()) {
+			if (!Character.isDigit(c)) {
+				return false;
+			}
+		}
+		return true;
+	}
+
+}

+ 2 - 2
ibps-provider-root/modules/provider-platform/src/main/resources/conf/dataSource-dev.xml

@@ -6,8 +6,8 @@
 
     <!-- dev下使用该链接 -->
     <dbType>mysql</dbType>
-    <driver>com.mysql.jdbc.Driver</driver>
-    <driverUrl>jdbc:mysql://192.168.2.161:3306/klims-ibps3?useUnicode=true&amp;characterEncoding=utf-8</driverUrl>
+    <driver>com.mysql.cj.jdbc.Driver</driver>
+    <driverUrl>jdbc:mysql://192.168.2.192:3306/klims-ibps3?useUnicode=true&amp;characterEncoding=utf-8&amp;allowMultiQueries=true&amp;useSSL=false&amp;allowPublicKeyRetrieval=true&amp;defaultAuthenticationPlugin=mysql_native_password&amp;serverTimezone=Asia/Shanghai</driverUrl>
     <user>root</user>
     <password>test001</password>
 

+ 1 - 1
ibps-starter-parent/pom.xml

@@ -68,7 +68,7 @@
         <hibernate-core.version>5.0.1.Final</hibernate-core.version>
         <hibernate-validator.version>5.0.1.Final</hibernate-validator.version>
         <hibernate-jpa-2.1-api.version>1.0.2.Final</hibernate-jpa-2.1-api.version>
-        <mysql.version>5.1.36</mysql.version>
+        <mysql.version>8.0.28</mysql.version>
         <oracle.version>11.2.0.2</oracle.version>
         <db2-jcc4.version>10.1</db2-jcc4.version>
         <postgresql-jre7.version>42.2.2.jre7</postgresql-jre7.version>