diff options
author | 2015-12-22 15:47:03 +0300 | |
---|---|---|
committer | 2015-12-22 15:47:03 +0300 | |
commit | 943b0e3875de3b99480115b6c28d7b113692c5cb (patch) | |
tree | 28fc9da3168aae331df1fb1d7a2f46359eef41fe /src/main/java/com/juick | |
parent | a22533b7653c00b2c982946c4b2894167c5ad9f9 (diff) |
refactoring
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r-- | src/main/java/com/juick/CrosspostComponent.java | 9 | ||||
-rw-r--r-- | src/main/java/com/juick/PushComponent.java | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/com/juick/CrosspostComponent.java b/src/main/java/com/juick/CrosspostComponent.java index 73791c5e..4c6a5002 100644 --- a/src/main/java/com/juick/CrosspostComponent.java +++ b/src/main/java/com/juick/CrosspostComponent.java @@ -82,7 +82,8 @@ public class CrosspostComponent implements ServletContextListener, Stream.Strea twitter_consumer_key = conf.getProperty("twitter_consumer_key", ""); twitter_consumer_secret = conf.getProperty("twitter_consumer_secret", ""); - setupSql(conf.getProperty("mysql_username", ""), conf.getProperty("mysql_password", "")); + setupSql(conf.getProperty("mysql_host"), conf.getProperty("mysql_username"), + conf.getProperty("mysql_password", ""), conf.getProperty("mysql_database", "")); setupXmppComponent(conf.getProperty("xmpp_password", "")); } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); @@ -97,9 +98,11 @@ public class CrosspostComponent implements ServletContextListener, Stream.Strea logger.info("component destroyed"); } - public void setupSql(String username, String password) { + public void setupSql(String host, String username, String password, String database) { try { - sql = DriverManager.getConnection("jdbc:mysql://localhost/juick?autoReconnect=true&user=" + username + "&password=" + password); + sql = DriverManager.getConnection( + String.format("jdbc:mysql://%s/%s?autoReconnect=true&user=%s&password=%s", + host, database, username, password)); } catch (SQLException e) { logger.log(Level.SEVERE, e.getMessage(), e); } diff --git a/src/main/java/com/juick/PushComponent.java b/src/main/java/com/juick/PushComponent.java index 9de598f3..f2c1ee74 100644 --- a/src/main/java/com/juick/PushComponent.java +++ b/src/main/java/com/juick/PushComponent.java @@ -76,7 +76,7 @@ public class PushComponent implements ServletContextListener, Stream.StreamListe public void run() { Properties conf = new Properties(); try { - conf.load(sce.getServletContext().getResourceAsStream("WEB-INF/push.conf")); + conf.load(sce.getServletContext().getResourceAsStream("WEB-INF/juick.conf")); GCMSender = new Sender(conf.getProperty("gcm_key")); setupSql(conf.getProperty("mysql_host"), conf.getProperty("mysql_username"), |