Commit d423bba5 authored by 马博's avatar 马博

fix

parent 58ce8cd3
...@@ -35,18 +35,18 @@ public class MysqlConnPool { ...@@ -35,18 +35,18 @@ public class MysqlConnPool {
@Value("${db.maxtotal}") @Value("${db.maxtotal}")
int maxtotal; int maxtotal;
public BasicDataSource bds; public static BasicDataSource bds;
public DuibaLog log = DuibaLog.getLogger(); public DuibaLog log = DuibaLog.getLogger();
public void initDataSource(){ public void initDataSource(){
if(bds != null){ if(bds != null){
return; return;
} }
synchronized (MysqlConnPool.class){ // synchronized (MysqlConnPool.class){
if(bds != null){ // if(bds != null){
return; // return;
} // }
System.out.println("初始化数据库"); log.info("初始化数据库");
BasicDataSource bds = new BasicDataSource(); BasicDataSource bds = new BasicDataSource();
bds.setDriverClassName(DRIVER); bds.setDriverClassName(DRIVER);
bds.setUrl(URL); bds.setUrl(URL);
...@@ -54,7 +54,7 @@ public class MysqlConnPool { ...@@ -54,7 +54,7 @@ public class MysqlConnPool {
bds.setPassword(PASSWORD); bds.setPassword(PASSWORD);
bds.setMaxTotal(maxtotal); bds.setMaxTotal(maxtotal);
this.bds = bds; this.bds = bds;
} // }
} }
/** /**
...@@ -66,11 +66,14 @@ public class MysqlConnPool { ...@@ -66,11 +66,14 @@ public class MysqlConnPool {
*/ */
public Map<String, Object> findSimpleResult(String sql, Object ...params) throws SQLException { public Map<String, Object> findSimpleResult(String sql, Object ...params) throws SQLException {
Map<String, Object> map = null; Map<String, Object> map = null;
try(Connection conn = bds.getConnection()){ try(Connection conn = bds.getConnection()){
map = new HashMap<String, Object>(); map = new HashMap<String, Object>();
int index = 1; int index = 1;
log.info("bds!=null");
PreparedStatement pstmt = conn.prepareStatement(sql); PreparedStatement pstmt = conn.prepareStatement(sql);
log.info("conn!=null");
log.info(conn.toString()); log.info(conn.toString());
if(params != null && !(params.length==0)){ if(params != null && !(params.length==0)){
for(int i=0; i<params.length; i++){ for(int i=0; i<params.length; i++){
...@@ -97,7 +100,10 @@ public class MysqlConnPool { ...@@ -97,7 +100,10 @@ public class MysqlConnPool {
// } // }
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); // e.printStackTrace();
log.info("findSimpleResult"+e.toString());
log.info("test");
log.info("bds"+bds.toString());
} }
return map; return map;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment