1
This commit is contained in:
parent
0f6436e8fe
commit
2a6766ff89
6
pom.xml
6
pom.xml
@ -40,7 +40,11 @@
|
|||||||
<artifactId>postgresql</artifactId>
|
<artifactId>postgresql</artifactId>
|
||||||
<version>${postgresql.version}</version>
|
<version>${postgresql.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.27</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package sdk_996.mapper;
|
package sdk_996.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
@ -9,9 +10,13 @@ import java.util.Map;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SqlExecuteMapper extends BaseMapper<Object> {
|
public interface SqlExecuteMapper extends BaseMapper<Object> {
|
||||||
|
@DS("master_1")
|
||||||
@Select("${value}")
|
@Select("${value}")
|
||||||
List<Map<String, Object>> sqlQuery(String value);
|
List<Map<String, Object>> sql_pgsql_Query(String value);
|
||||||
|
|
||||||
|
@DS("master_2")
|
||||||
|
@Select("${value}")
|
||||||
|
List<Map<String, Object>> sql_mysql_Query(String value);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class SqlExecuteService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SqlExecuteMapper sqlExecuteMapper;
|
private SqlExecuteMapper sqlExecuteMapper;
|
||||||
|
|
||||||
public JSONObject performCustomQuery(String sqlstr) {
|
public JSONObject performCustomQuery(String sqlstr) {
|
||||||
// 返回的json对象
|
// 返回的json对象
|
||||||
JSONObject returnJsonObject = new JSONObject();
|
JSONObject returnJsonObject = new JSONObject();
|
||||||
JSONObject sqlJsonObject;
|
JSONObject sqlJsonObject;
|
||||||
@ -70,7 +70,7 @@ public class SqlExecuteService {
|
|||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
// 执行 SQL 查询
|
// 执行 SQL 查询
|
||||||
List<Map<String, Object>> resultList = sqlExecuteMapper.sqlQuery(sqlStr);
|
List<Map<String, Object>> resultList = sqlExecuteMapper.sql_mysql_Query(sqlStr);
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
logger.info("sql执行时长:{}ms 执行sql:{}", (endTime - startTime), sqlStr);
|
logger.info("sql执行时长:{}ms 执行sql:{}", (endTime - startTime), sqlStr);
|
||||||
|
|
||||||
|
@ -16,6 +16,17 @@ spring:
|
|||||||
connection-timeout: 30000
|
connection-timeout: 30000
|
||||||
idle-timeout: 600000
|
idle-timeout: 600000
|
||||||
max-lifetime: 1800000
|
max-lifetime: 1800000
|
||||||
|
master_2:
|
||||||
|
url: jdbc:mysql://yin520.cn:3306/996
|
||||||
|
username: root
|
||||||
|
password: yin520.cn
|
||||||
|
driver-class-name: com.mysql.jdbc.Driver
|
||||||
|
hikari:
|
||||||
|
minimum-idle: 10
|
||||||
|
maximum-pool-size: 100
|
||||||
|
connection-timeout: 30000
|
||||||
|
idle-timeout: 600000
|
||||||
|
max-lifetime: 1800000
|
||||||
|
|
||||||
#logging:
|
#logging:
|
||||||
# level:
|
# level:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user