aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/jabber/ws/Main.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-24 15:06:58 +0300
committerGravatar Vitaly Takmazov2016-06-24 15:06:58 +0300
commit095dee1388919eac7d3a3fa6fc93767f82c16365 (patch)
tree094ecad722a7a99ecbbabfb370fbdf51d80e8f11 /src/main/java/com/juick/jabber/ws/Main.java
parent27e6c9c5edb2642c31735fcb0effb9acd82bd4af (diff)
spring-jdbc
Diffstat (limited to 'src/main/java/com/juick/jabber/ws/Main.java')
-rw-r--r--src/main/java/com/juick/jabber/ws/Main.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main/java/com/juick/jabber/ws/Main.java b/src/main/java/com/juick/jabber/ws/Main.java
index a7aea543..3a26c3ad 100644
--- a/src/main/java/com/juick/jabber/ws/Main.java
+++ b/src/main/java/com/juick/jabber/ws/Main.java
@@ -17,8 +17,10 @@
*/
package com.juick.jabber.ws;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
+
import java.io.FileInputStream;
-import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -30,7 +32,7 @@ import java.util.Properties;
*/
public class Main {
- Connection sql;
+ JdbcTemplate sql;
XMPPConnection xmpp;
public static String STATSFILE = null;
public final static ArrayList<SocketSubscribed> clients = new ArrayList<SocketSubscribed>();
@@ -46,7 +48,7 @@ public class Main {
STATSFILE = conf.getProperty("statsfile");
- setupSql(conf.getProperty("mysql_username", ""), conf.getProperty("mysql_password", ""));
+ setupSql(conf.getProperty("datasource_driver", "com.mysql.jdbc.Driver"), conf.getProperty("datasource_url"));
xmpp = new XMPPConnection(sql, conf.getProperty("xmpp_password", ""));
new Thread(xmpp).start();
@@ -58,11 +60,10 @@ public class Main {
}
}
- public void setupSql(String username, String password) {
- try {
- sql = DriverManager.getConnection("jdbc:mysql://localhost/juick?autoReconnect=true&user=" + username + "&password=" + password);
- } catch (SQLException e) {
- System.err.println(e);
- }
+ public void setupSql(String driver, String url) {
+ DriverManagerDataSource dataSource = new DriverManagerDataSource();
+ dataSource.setDriverClassName(driver);
+ dataSource.setUrl(url);
+ sql = new JdbcTemplate(dataSource);
}
} \ No newline at end of file