From 93d05aaa41f910222f233a6faa8d38750f9f1695 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 18 May 2017 13:27:27 +0900 Subject: [PATCH] class.4name --- pom.xml | 2 +- .../loafle/overflow/crawler/sql/SQLCrawler.java | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 61c1d5f..ccfa759 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.loafle.overflow crawler_sql - 1.0.6-SNAPSHOT + 1.0.0-SNAPSHOT diff --git a/src/main/java/com/loafle/overflow/crawler/sql/SQLCrawler.java b/src/main/java/com/loafle/overflow/crawler/sql/SQLCrawler.java index a2db85b..96ca0ec 100644 --- a/src/main/java/com/loafle/overflow/crawler/sql/SQLCrawler.java +++ b/src/main/java/com/loafle/overflow/crawler/sql/SQLCrawler.java @@ -19,12 +19,11 @@ public class SQLCrawler extends Crawler { public SQLCrawler() {} @Override - public Object getInternal(Config config) { + public Object getInternal(Config config) throws Exception { return getMetrics(config); } - - private Object getMetrics(Config config) { + private Object getMetrics(Config config) throws Exception { Connection conn = null; Statement stmt = null; @@ -37,13 +36,13 @@ public class SQLCrawler extends Crawler { try { if (url.contains("mysql")) { Class.forName("com.mysql.jdbc.Driver"); - }else if (url.contains("pgsql")) { + }else if (url.contains("postgresql")) { Class.forName("org.postgresql.Driver"); }else if (url.contains("sqlserver")) { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); } }catch(Exception e) { - + e.printStackTrace(); } List resultSets = new ArrayList<>(); @@ -72,14 +71,10 @@ public class SQLCrawler extends Crawler { resultSets.add(resultSet); rs.close(); } - if (resultSets.size() <= 0) { - return new Exception("No data found."); - } return resultSets; } catch (Exception e) { - e.printStackTrace(); - return e; + throw e; } finally { if (conn != null) {try {conn.close();} catch (SQLException e) {e.printStackTrace();}} if (rs != null) {try {rs.close();} catch (SQLException e) {e.printStackTrace();}}