aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/CrosspostComponent.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2015-12-22 15:47:03 +0300
committerGravatar Vitaly Takmazov2015-12-22 15:47:03 +0300
commit943b0e3875de3b99480115b6c28d7b113692c5cb (patch)
tree28fc9da3168aae331df1fb1d7a2f46359eef41fe /src/main/java/com/juick/CrosspostComponent.java
parenta22533b7653c00b2c982946c4b2894167c5ad9f9 (diff)
refactoring
Diffstat (limited to 'src/main/java/com/juick/CrosspostComponent.java')
-rw-r--r--src/main/java/com/juick/CrosspostComponent.java9
1 files changed, 6 insertions, 3 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);
}