Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马博
test-platform
Commits
d423bba5
Commit
d423bba5
authored
Nov 16, 2018
by
马博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
58ce8cd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
MysqlConnPool.java
src/test/java/base/MysqlConnPool.java
+14
-8
No files found.
src/test/java/base/MysqlConnPool.java
View file @
d423bba5
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment