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