diff --git a/pom.xml b/pom.xml
index da62685..9a06bd7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -637,6 +637,14 @@
fastdfs-client-java
1.27-SNAPSHOT
+
+
+
+ com.alibaba
+ druid
+ 1.1.10
+
+
diff --git a/src/main/java/com/nis/util/HiveJDBC.java b/src/main/java/com/nis/util/HiveJDBC.java
index 81ce4ec..5ee83d0 100644
--- a/src/main/java/com/nis/util/HiveJDBC.java
+++ b/src/main/java/com/nis/util/HiveJDBC.java
@@ -40,24 +40,16 @@ public class HiveJDBC {
static {
try {
prop.load(Configurations.class.getResourceAsStream("/jdbc.properties"));
+ driverName = prop.getProperty("jdbc.hive.driver").trim();
+ url = prop.getProperty("jdbc.hive.url").trim();
+ username = prop.getProperty("jdbc.hive.username").trim();
+ password = prop.getProperty("jdbc.hive.password").trim();
} catch (IOException e) {
e.printStackTrace();
}
}
- public static void getConn(String searchActiveSys) throws Exception {
-
- if (null != searchActiveSys && searchActiveSys.equals("4")) {
- driverName = prop.getProperty("jdbc.hiveA.driver").trim();
- url = prop.getProperty("jdbc.hiveA.url").trim();
- username = prop.getProperty("jdbc.hiveA.username").trim();
- password = prop.getProperty("jdbc.hiveA.password").trim();
- } else {
- driverName = prop.getProperty("jdbc.hiveB.driver").trim();
- url = prop.getProperty("jdbc.hiveB.url").trim();
- username = prop.getProperty("jdbc.hiveB.username").trim();
- password = prop.getProperty("jdbc.hiveB.password").trim();
- }
+ public static void getConn() throws Exception {
Class.forName(driverName);
conn = DriverManager.getConnection(url, username, password);
@@ -65,7 +57,7 @@ public class HiveJDBC {
public static ResultSet query(String sql, String searchActiveSys) throws Exception {
logger.info("开始连接数据中心日志库--------------------------");
- getConn(searchActiveSys);
+ getConn();
logger.info("连接数据中心日志库成功--------------------------");
st = conn.createStatement();
if (null != searchActiveSys && searchActiveSys.equals("4")) {
@@ -135,15 +127,15 @@ public class HiveJDBC {
Map filedAndColumnMap = getColumn2FiledMap(entityClass);
List listString = new ArrayList();
List listObject = new ArrayList();
- //不从Object... obj中获取需要date类型的字段了,调用的时候容易漏写,改为反射获取date类型的字段
- List columnList =getDateColumn(entityClass);
-// List columnList =null;
-// if (null != obj && obj.length > 0) {
-// columnList = new ArrayList();
-// for (int i = 0; i < obj.length; i++) {
-// columnList.add(obj[i].toString().toLowerCase());
-// }
-// }
+ // 不从Object... obj中获取需要date类型的字段了,调用的时候容易漏写,改为反射获取date类型的字段
+ List columnList = getDateColumn(entityClass);
+ // List columnList =null;
+ // if (null != obj && obj.length > 0) {
+ // columnList = new ArrayList();
+ // for (int i = 0; i < obj.length; i++) {
+ // columnList.add(obj[i].toString().toLowerCase());
+ // }
+ // }
// ResultSet rs = HiveJDBC.query(sql.toString());
ResultSetMetaData metaData = rs.getMetaData();
while (rs.next()) {
@@ -152,11 +144,11 @@ public class HiveJDBC {
Object value = rs.getObject(i);
String filedName = filedAndColumnMap.get(metaData.getColumnName(i).toString().toLowerCase());
if (!StringUtil.isEmpty(value)) {
- //如果是日期类型的属性需要把时间戳转换成日期,如果时间戳为0直接把值设置为null
+ // 如果是日期类型的属性需要把时间戳转换成日期,如果时间戳为0直接把值设置为null
if (null != columnList && columnList.contains(filedName.toLowerCase())) {
long time = 0l;
time = Long.parseLong(value.toString());
- map.put(filedName, time==0l?null:new Date(time * 1000));
+ map.put(filedName, time == 0l ? null : new Date(time * 1000));
// map.put(filedName, new
// Date(Long.parseLong("1476583810000")));
} else {
diff --git a/src/main/java/com/nis/web/controller/restful/LogController.java b/src/main/java/com/nis/web/controller/restful/LogController.java
index 8ca3b30..8bf1386 100644
--- a/src/main/java/com/nis/web/controller/restful/LogController.java
+++ b/src/main/java/com/nis/web/controller/restful/LogController.java
@@ -1,6 +1,5 @@
package com.nis.web.controller.restful;
-import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
@@ -24,7 +23,7 @@ import com.nis.restful.RestServiceException;
import com.nis.util.Configurations;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
-import com.nis.util.HiveJDBC;
+import com.nis.util.HiveJDBCByDruid;
import com.nis.util.JsonMapper;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
@@ -74,10 +73,10 @@ public class LogController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, dkBehaviorLog,
+ String sql = HiveSqlService.getSql(page, dkBehaviorLog,
Configurations.getStringProperty(DkBehaviorLog.class.getSimpleName() + "HiveTable", "DK_BEHAVIOR_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, DkBehaviorLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, DkBehaviorLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -127,10 +126,10 @@ public class LogController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, pxyHttpLog,
+ String sql = HiveSqlService.getSql(page, pxyHttpLog,
Configurations.getStringProperty(PxyHttpLog.class.getSimpleName() + "HiveTable", "PXY_HTTP_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, PxyHttpLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, PxyHttpLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
diff --git a/src/main/java/com/nis/web/controller/restful/MmLogSearchController.java b/src/main/java/com/nis/web/controller/restful/MmLogSearchController.java
index 4cc618e..606cf01 100644
--- a/src/main/java/com/nis/web/controller/restful/MmLogSearchController.java
+++ b/src/main/java/com/nis/web/controller/restful/MmLogSearchController.java
@@ -1,6 +1,5 @@
package com.nis.web.controller.restful;
-import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
@@ -34,7 +33,7 @@ import com.nis.restful.RestServiceException;
import com.nis.util.Configurations;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
-import com.nis.util.HiveJDBC;
+import com.nis.util.HiveJDBCByDruid;
import com.nis.util.JsonMapper;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
@@ -83,10 +82,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmAvIpLog,
+ String sql = HiveSqlService.getSql(page, mmAvIpLog,
Configurations.getStringProperty(MmAvIpLog.class.getSimpleName() + "HiveTable", "MM_AV_IP_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmAvIpLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmAvIpLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -136,10 +135,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmAvUrlLog,
+ String sql = HiveSqlService.getSql(page, mmAvUrlLog,
Configurations.getStringProperty(MmAvUrlLog.class.getSimpleName() + "HiveTable", "MM_AV_URL_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmAvUrlLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmAvUrlLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -189,10 +188,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmPicIpLog,
+ String sql = HiveSqlService.getSql(page, mmPicIpLog,
Configurations.getStringProperty(MmPicIpLog.class.getSimpleName() + "HiveTable", "MM_PIC_IP_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmPicIpLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmPicIpLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -242,10 +241,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmPicUrlLog,
+ String sql = HiveSqlService.getSql(page, mmPicUrlLog,
Configurations.getStringProperty(MmPicUrlLog.class.getSimpleName() + "HiveTable", "MM_PIC_URL_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmPicUrlLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmPicUrlLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -296,10 +295,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmVoipIpLog,
+ String sql = HiveSqlService.getSql(page, mmVoipIpLog,
Configurations.getStringProperty(MmVoipIpLog.class.getSimpleName() + "HiveTable", "MM_VOIP_IP_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmVoipIpLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmVoipIpLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -349,10 +348,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmVoipLog,
+ String sql = HiveSqlService.getSql(page, mmVoipLog,
Configurations.getStringProperty(MmVoipAccountLog.class.getSimpleName() + "HiveTable", "MM_VOIP_ACCOUNT_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmVoipAccountLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmVoipAccountLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -403,10 +402,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmSampleAudioLog,
+ String sql = HiveSqlService.getSql(page, mmSampleAudioLog,
Configurations.getStringProperty(MmSampleAudioLog.class.getSimpleName() + "HiveTable", "MM_SAMPLE_AUDIO_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmSampleAudioLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmSampleAudioLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -456,10 +455,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmSampleVideoLog,
+ String sql = HiveSqlService.getSql(page, mmSampleVideoLog,
Configurations.getStringProperty(MmSampleVideoLog.class.getSimpleName() + "HiveTable", "MM_SAMPLE_VIDEO_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmSampleVideoLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmSampleVideoLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -509,10 +508,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmPornAudioLevelLog,
+ String sql = HiveSqlService.getSql(page, mmPornAudioLevelLog,
Configurations.getStringProperty(MmPornAudioLevelLog.class.getSimpleName() + "HiveTable", "MM_PORN_AUDIO_LEVEL_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmPornAudioLevelLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmPornAudioLevelLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -562,10 +561,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmPornVideoLevelLog,
+ String sql = HiveSqlService.getSql(page, mmPornVideoLevelLog,
Configurations.getStringProperty(MmPornVideoLevelLog.class.getSimpleName() + "HiveTable", "MM_PRON_VIDEO_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmPornVideoLevelLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmPornVideoLevelLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -616,10 +615,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmSamplePicLog,
+ String sql = HiveSqlService.getSql(page, mmSamplePicLog,
Configurations.getStringProperty(MmSamplePicLog.class.getSimpleName() + "HiveTable", "MM_SAMPLE_PIC_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmSamplePicLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmSamplePicLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
@@ -669,10 +668,10 @@ public class MmLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, mmSampleVoipLog,
+ String sql = HiveSqlService.getSql(page, mmSampleVoipLog,
Configurations.getStringProperty(MmSampleVoipLog.class.getSimpleName() + "HiveTable", "MM_SAMPLE_VOIP_LOG"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, MmSampleVoipLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null, sql, MmSampleVoipLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
logPage.setList(new ArrayList());
diff --git a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java
index 8d044ee..878a4e9 100644
--- a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java
+++ b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java
@@ -36,6 +36,7 @@ import com.nis.util.Configurations;
import com.nis.util.Constants;
import com.nis.util.DateUtils;
import com.nis.util.HiveJDBC;
+import com.nis.util.HiveJDBCByDruid;
import com.nis.util.JsonMapper;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.AuditLogThread;
@@ -82,15 +83,20 @@ public class NtcLogSearchController extends BaseRestController {
} else {
orderBy = "found_Time";
}
- ResultSet rs = HiveSqlService.getResultSet(page, ntcIpLog,
+// ResultSet rs = HiveSqlService.getResultSet(page, ntcIpLog,
+// Configurations.getStringProperty(NtcIpLog.class.getSimpleName() + "HiveTable", "ntc_ip_log"),
+// getCol2Col(), orderBy, null);
+// Map tableMapping = HiveJDBC.tableMapping(page, null, rs, NtcIpLog.class, "foundTime",
+// "recvTime");
+ String sql = HiveSqlService.getSql(page, ntcIpLog,
Configurations.getStringProperty(NtcIpLog.class.getSimpleName() + "HiveTable", "ntc_ip_log"),
getCol2Col(), orderBy, null);
- Map tableMapping = HiveJDBC.tableMapping(page, null, rs, NtcIpLog.class, "foundTime",
+ Map> tableMapping = new HiveJDBCByDruid().tableMapping(page, null,sql , NtcIpLog.class, "foundTime",
"recvTime");
if (tableMapping == null) {
- ntcIpLogPage.setList(new ArrayList());
+ ntcIpLogPage.setList(new ArrayList());
} else {
- List list = new ArrayList();
+ List