Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
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
YZG
yzg-util
Commits
d3ed698b
Commit
d3ed698b
authored
Sep 15, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实例化关系
parent
b96db6b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
DbPrintSql.java
...-db/src/main/java/com/yanzuoguang/db/impl/DbPrintSql.java
+18
-9
No files found.
yzg-util-db/src/main/java/com/yanzuoguang/db/impl/DbPrintSql.java
View file @
d3ed698b
...
@@ -29,12 +29,17 @@ public class DbPrintSql {
...
@@ -29,12 +29,17 @@ public class DbPrintSql {
// 进行SQL语句参数替换,后面增加一个空格,方便后续用正则表达式进行替换处理
// 进行SQL语句参数替换,后面增加一个空格,方便后续用正则表达式进行替换处理
String
[]
split
=
sql
.
split
(
"\\?"
);
String
[]
split
=
sql
.
split
(
"\\?"
);
// 参数位置
int
pos
=
0
;
int
pos
=
0
;
// 循环获取参数
while
(
pos
<
split
.
length
)
{
while
(
pos
<
split
.
length
)
{
// 获取位置信息
sb
.
append
(
split
[
pos
]);
sb
.
append
(
split
[
pos
]);
// 获取位置
if
(
pos
==
split
.
length
-
1
)
{
if
(
pos
==
split
.
length
-
1
)
{
break
;
break
;
}
}
// 获取对象
Object
item
=
paras
.
length
>
pos
?
paras
[
pos
]
:
null
;
Object
item
=
paras
.
length
>
pos
?
paras
[
pos
]
:
null
;
String
str
=
StringHelper
.
toString
(
item
);
String
str
=
StringHelper
.
toString
(
item
);
String
strTo
=
str
;
String
strTo
=
str
;
...
@@ -64,17 +69,21 @@ public class DbPrintSql {
...
@@ -64,17 +69,21 @@ public class DbPrintSql {
* @param paras 参数
* @param paras 参数
*/
*/
public
void
print
(
Class
targetClass
,
String
sqlName
,
long
start
,
int
row
,
String
sql
,
Object
...
paras
)
{
public
void
print
(
Class
targetClass
,
String
sqlName
,
long
start
,
int
row
,
String
sql
,
Object
...
paras
)
{
// 日志表忽略打印
try
{
if
(!
configDb
.
isPrintSql
())
{
// 日志表忽略打印
return
;
if
(!
configDb
.
isPrintSql
())
{
}
if
(!
StringHelper
.
isEmpty
(
configDb
.
getPrintSqlFilter
()))
{
if
(
sql
.
matches
(
configDb
.
getPrintSqlFilter
()))
{
return
;
return
;
}
}
if
(!
StringHelper
.
isEmpty
(
configDb
.
getPrintSqlFilter
()))
{
if
(
sql
.
matches
(
configDb
.
getPrintSqlFilter
()))
{
return
;
}
}
sql
=
getStringSql
(
sql
,
paras
);
// 打印SQL语句
Log
.
infoTag
(
DbPrintSql
.
class
,
String
.
format
(
"%d row %s.%s"
,
row
,
targetClass
.
getSimpleName
(),
sqlName
),
sql
);
}
catch
(
Exception
ex
)
{
Log
.
error
(
DbPrintSql
.
class
,
ex
);
}
}
sql
=
getStringSql
(
sql
,
paras
);
// 打印SQL语句
Log
.
infoTag
(
DbPrintSql
.
class
,
String
.
format
(
"%d row %s.%s"
,
row
,
targetClass
.
getSimpleName
(),
sqlName
),
sql
);
}
}
}
}
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