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
Show 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 {
...
@@ -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
;
...
...
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