代码更新
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package org.nl.modules.wql.core.db;
|
||||
|
||||
import cn.hutool.db.Db;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.wql.WQLCore;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
@@ -169,7 +169,9 @@ public class DBConnection {
|
||||
name = WQLCore.defalutDBName;
|
||||
}
|
||||
DataSource dataSource = (DataSource) SpringContextHolder.getApplicationContext().getBean(name);
|
||||
DataSourceUtils.releaseConnection(conn, dataSource);
|
||||
// DataSourceUtils.releaseConnection(conn, dataSource);
|
||||
|
||||
Db.use(dataSource).closeConnection(conn);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package org.nl.modules.wql.core.db;
|
||||
|
||||
import cn.hutool.db.Db;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.wql.WQLCore;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.jdbc.datasource.DataSourceUtils;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
@@ -78,8 +77,9 @@ public class DBPoolSpring {
|
||||
public static Connection getConnection(String name) {
|
||||
Connection conn = null;
|
||||
try {
|
||||
DataSource dataSource = (DataSource) SpringContextHolder.getBean(name);
|
||||
conn = DataSourceUtils.getConnection(dataSource);
|
||||
DataSource dataSource = SpringContextHolder.getBean(name);
|
||||
conn=Db.use(dataSource).getConnection();
|
||||
// conn = DataSourceUtils.getConnection(dataSource);
|
||||
} catch (Exception e) {
|
||||
log.error("不能获得Spring连接池中的数据库连接:" + e.toString());
|
||||
}
|
||||
@@ -120,7 +120,9 @@ public class DBPoolSpring {
|
||||
// conn.close();
|
||||
// }
|
||||
DataSource dataSource = (DataSource) SpringContextHolder.getBean(name);
|
||||
DataSourceUtils.releaseConnection(conn, dataSource);
|
||||
// DataSourceUtils.releaseConnection(conn, dataSource);
|
||||
|
||||
Db.use(dataSource).closeConnection(conn);
|
||||
// } catch (SQLException e) {
|
||||
// log.error("数据库连接关闭:"+e.toString() );
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user