sql crawler

This commit is contained in:
insanity 2017-04-13 13:49:58 +09:00
parent e206016ad8
commit 0d414b3b8f
3 changed files with 7 additions and 9 deletions

View File

@ -45,7 +45,7 @@
<dependency> <dependency>
<groupId>com.loafle.overflow</groupId> <groupId>com.loafle.overflow</groupId>
<artifactId>crawler_java</artifactId> <artifactId>crawler</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</dependency> </dependency>

View File

@ -21,7 +21,7 @@ public class SQLCrawler extends Crawler {
} }
private List<Map<String, String>> getMetrics(Map<String, Object> config) { private Object getMetrics(Map<String, Object> config) {
Connection conn = null; Connection conn = null;
Statement stmt = null; Statement stmt = null;
@ -58,8 +58,7 @@ public class SQLCrawler extends Crawler {
return datas; return datas;
} catch (Exception e) { } catch (Exception e) {
new Exception(e.getMessage()).printStackTrace();
e.printStackTrace();
} finally { } finally {
if (conn != null) { if (conn != null) {
@ -87,7 +86,6 @@ public class SQLCrawler extends Crawler {
} }
} }
return null; return null;
} }

View File

@ -1,8 +1,8 @@
package com.loafle.overflow; package com.loafle.overflow;
import com.loafle.overflow.crawler.Crawler;
import com.loafle.overflow.crawler.sql.SQLCrawler; import com.loafle.overflow.crawler.sql.SQLCrawler;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import java.util.HashMap; import java.util.HashMap;
@ -36,6 +36,7 @@ public class AppTest {
// info.setQuery("select * from v$sysstat"); // info.setQuery("select * from v$sysstat");
@Test @Test
@Ignore
public void testSQL() { public void testSQL() {
SQLCrawler sc = new SQLCrawler(); SQLCrawler sc = new SQLCrawler();
Map config = new HashMap(); Map config = new HashMap();
@ -45,9 +46,8 @@ public class AppTest {
config.put("ssl", false); config.put("ssl", false);
config.put("query", "show session status"); config.put("query", "show session status");
List<Map<String,String>> result = (List<Map<String,String>>)sc.getInternal(config); Object result = sc.getInternal(config);
for(Map<String, String> m : (List<Map<String,String>>)result) {
for(Map<String, String> m : result) {
for (Map.Entry<String, String> entry : m.entrySet()) { for (Map.Entry<String, String> entry : m.entrySet()) {
System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
} }