Commit d423bba5 authored by 马博's avatar 马博

fix

parent 58ce8cd3
......@@ -35,18 +35,18 @@ public class MysqlConnPool {
@Value("${db.maxtotal}")
int maxtotal;
public BasicDataSource bds;
public static BasicDataSource bds;
public DuibaLog log = DuibaLog.getLogger();
public void initDataSource(){
if(bds != null){
return;
}
synchronized (MysqlConnPool.class){
if(bds != null){
return;
}
System.out.println("初始化数据库");
// synchronized (MysqlConnPool.class){
// if(bds != null){
// return;
// }
log.info("初始化数据库");
BasicDataSource bds = new BasicDataSource();
bds.setDriverClassName(DRIVER);
bds.setUrl(URL);
......@@ -54,7 +54,7 @@ public class MysqlConnPool {
bds.setPassword(PASSWORD);
bds.setMaxTotal(maxtotal);
this.bds = bds;
}
// }
}
/**
......@@ -66,11 +66,14 @@ public class MysqlConnPool {
*/
public Map<String, Object> findSimpleResult(String sql, Object ...params) throws SQLException {
Map<String, Object> map = null;
try(Connection conn = bds.getConnection()){
map = new HashMap<String, Object>();
int index = 1;
log.info("bds!=null");
PreparedStatement pstmt = conn.prepareStatement(sql);
log.info("conn!=null");
log.info(conn.toString());
if(params != null && !(params.length==0)){
for(int i=0; i<params.length; i++){
......@@ -97,7 +100,10 @@ public class MysqlConnPool {
// }
}catch(Exception e){
e.printStackTrace();
// e.printStackTrace();
log.info("findSimpleResult"+e.toString());
log.info("test");
log.info("bds"+bds.toString());
}
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