shjung 3 éve
szülő
commit
f4eb62ad11

+ 1 - 2
src/main/java/com/its/op/scheduler/ItsApiScheduler.java

@@ -76,8 +76,7 @@ public class ItsApiScheduler {
      * DB Server Stts Update
      */
     @Async
-    //@Scheduled(cron = "40 0/1 * * * *")  // 5분 주기 작업 실행
-    @Scheduled(cron = "0/10 * * * * *")  // 5분 주기 작업 실행
+    @Scheduled(cron = "40 0/10 * * * *")  // 5분 주기 작업 실행
     public void jobDbSvrStts() {
         if (this.jobConfig.isDbSvrStts()) {
             this.dbSvrSttsJobThread.run();

+ 10 - 4
src/main/java/com/its/op/scheduler/job/DbSvrSttsJobThread.java

@@ -14,6 +14,7 @@ import javax.annotation.PostConstruct;
 import java.sql.*;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
 
 @Slf4j
 @AllArgsConstructor
@@ -91,11 +92,15 @@ public class DbSvrSttsJobThread {
         Connection conn = null;
         try {
             Class.forName(this.JDBC_DRIVER);
+            DriverManager.setLoginTimeout(10);
+            Properties properties = new Properties();
+            properties.put("connectTimeout", "2000");
             conn = DriverManager.getConnection(dbUrl, this.username, this.password);
 
             String TBLS_NM = "";
             double TBLS_RMND_CPCT = 100.0;
             PreparedStatement stmt1 = conn.prepareStatement(sql1);
+            stmt1.setQueryTimeout(10);
             ResultSet rs1 = stmt1.executeQuery();
             while(rs1.next()) {
                 String tblsNm = rs1.getString("TBLS_NM");
@@ -111,6 +116,7 @@ public class DbSvrSttsJobThread {
             stmt1.close();
 
             PreparedStatement stmt2 = conn.prepareStatement(sql2);
+            stmt2.setQueryTimeout(10);
             ResultSet rs2 = stmt2.executeQuery();
             while(rs2.next()) {
                 Double useSesn = rs2.getDouble("USE_SESN");
@@ -120,12 +126,12 @@ public class DbSvrSttsJobThread {
             stmt2.close();
         }
         catch(SQLException e) {
-            log.error("executeDbSvrStts: SQLException, {}, {}", db.getDbSvrIp(), e.getMessage());
-            throw new RuntimeException(e.getMessage(), e);
+            log.error("executeDbSvrStts: SQLException, {}, {}, {}", dbUrl, db.getDbSvrIp(), e.getMessage());
+            throw new RuntimeException(dbUrl + e.getMessage(), e);
         }
         catch (ClassNotFoundException e) {
-            log.error("executeDbSvrStts: ClassNotFoundException, {}, {}", db.getDbSvrIp(), e.getMessage());
-            throw new RuntimeException(e.getMessage(), e);
+            log.error("executeDbSvrStts: ClassNotFoundException, {}, {}, {}", dbUrl, db.getDbSvrIp(), e.getMessage());
+            throw new RuntimeException(dbUrl + e.getMessage(), e);
         }
         finally {
             if (conn != null) {