Toggle navigation
Toggle navigation
This project
Loading...
Sign in
guizhou-monitorV2.0.1
/
agent
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
zhangmingm
8 years ago
Commit
bf6ba254aaaec06c2137dac13164c516ba26450f
1 parent
23ec35f0
添加deleteBeforeData方法,删除内存数据库中历史数据。
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletions
src/com/sitech/ismp/check/downtime/CheckConnectionDao.java
src/com/sitech/ismp/check/downtime/CheckConnectionDao.java
View file @
bf6ba25
...
...
@@ -6,6 +6,7 @@ import org.apache.log4j.Logger;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -34,18 +35,34 @@ public class CheckConnectionDao {
/**
* 插入ping结果。
* 插入ping结果。
在插入数据之前,删除掉当前时间前1小时的数据,即只保留1小时的数据。
* @param bean
*/
public
void
addPingConnectionState
(
ConnectionStateBean
bean
){
try
{
deleteBeforeData
();
sqlmapClient
.
insert
(
"addPingConnectionState"
,
bean
);
log
.
info
(
"******* CheckConnectionDao **** execute method addPingConnectionState ******"
);
}
catch
(
SQLException
e
)
{
log
.
error
(
"Exception while addPingConnectionState."
,
e
);
}
}
/**
* 清除TB_CONNECTION_STATE表里1小时前的数据。
*/
public
void
deleteBeforeData
(){
long
temp
=
new
Date
().
getTime
()-
1000
*
60
*
60
;
String
sql
=
"DELETE from TB_CONNECTION_STATE where CREATE_DATE < "
+
temp
;
log
.
info
(
"******* deleteBeforeData **** sql["
+
sql
+
"]******"
);
try
{
sqlmapClient
.
delete
(
"deleteBeforeData"
,
sql
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Exception while deleteBeforeData()"
,
e
);
}
}
/**
* 根据IP获取该IP对应ping不通的次数。
* @param map
...
...
Please
register
or
login
to post a comment