param map => Config

This commit is contained in:
jackdaw@loafle.com 2017-04-14 10:39:33 +09:00
parent ec8ba81cb8
commit 94f168567b

View File

@ -1,6 +1,7 @@
package com.loafle.overflow.crawler.sql; package com.loafle.overflow.crawler.sql;
import com.loafle.overflow.crawler.Crawler; import com.loafle.overflow.crawler.Crawler;
import com.loafle.overflow.crawler.config.Config;
import java.sql.*; import java.sql.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -16,24 +17,25 @@ public class SQLCrawler extends Crawler {
public SQLCrawler() {} public SQLCrawler() {}
@Override @Override
public Object getInternal(Map<String, Object> config) { public Object getInternal(Config config) {
return getMetrics(config); return getMetrics(config);
} }
private Object getMetrics(Map<String, Object> config) { private Object getMetrics(Config config) {
Connection conn = null; Connection conn = null;
Statement stmt = null; Statement stmt = null;
ResultSet rs = null; ResultSet rs = null;
try { try {
conn = DriverManager.getConnection( // conn = DriverManager.getConnection(
(String)config.get("url"), // (String)config.get("url"),
(String)config.get("user"), // (String)config.get("user"),
(String)config.get("pw")); // (String)config.get("pw"));
stmt = conn.createStatement(); stmt = conn.createStatement();
rs = stmt.executeQuery((String)config.get("query")); // rs = stmt.executeQuery((String)config.get("query"));
ResultSetMetaData md = rs.getMetaData(); ResultSetMetaData md = rs.getMetaData();
int cnt = md.getColumnCount(); int cnt = md.getColumnCount();