From c19397fb6d4635120a1a8cdaef6d66f0b36e3c4b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 20 Jul 2016 15:12:34 +0300 Subject: DriverManagerDataSource -> BasicDataSource --- juick-api/build.gradle | 1 + juick-api/src/main/java/com/juick/api/Main.java | 4 ++-- juick-rss/build.gradle | 1 + juick-rss/src/main/java/com/juick/rss/Main.java | 4 ++-- juick-ws/build.gradle | 1 + .../java/com/juick/ws/configuration/WebsocketConfiguration.java | 7 ++----- juick-www/build.gradle | 1 + juick-www/src/main/java/com/juick/www/Main.java | 6 +++--- juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java | 4 +++- 9 files changed, 16 insertions(+), 13 deletions(-) diff --git a/juick-api/build.gradle b/juick-api/build.gradle index e1533883..4b8ce36a 100644 --- a/juick-api/build.gradle +++ b/juick-api/build.gradle @@ -26,6 +26,7 @@ dependencies { compile 'com.github.pengrad:java-telegram-bot-api:2.1.1' compile 'org.msbotframework4j:msbotframework4j-builder:0.1.4' compile 'com.neovisionaries:nv-websocket-client:1.27' + compile 'org.apache.commons:commons-dbcp2:2.0' providedRuntime 'mysql:mysql-connector-java:5.1.39' } compileJava.options.encoding = 'UTF-8' diff --git a/juick-api/src/main/java/com/juick/api/Main.java b/juick-api/src/main/java/com/juick/api/Main.java index 5a495ba2..676aab79 100644 --- a/juick-api/src/main/java/com/juick/api/Main.java +++ b/juick-api/src/main/java/com/juick/api/Main.java @@ -30,8 +30,8 @@ import com.juick.xmpp.StreamComponent; import com.juick.xmpp.extensions.JuickMessage; import com.juick.xmpp.extensions.Nickname; import com.juick.xmpp.extensions.XOOB; +import org.apache.commons.dbcp2.BasicDataSource; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.DriverManagerDataSource; import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; @@ -75,7 +75,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { LogManager.getLogManager().readConfiguration(getServletContext().getResourceAsStream("/WEB-INF/logging.properties")); Properties conf = new Properties(); conf.load(getServletContext().getResourceAsStream("/WEB-INF/juick.conf")); - DriverManagerDataSource dataSource = new DriverManagerDataSource(); + BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(conf.getProperty("datasource_driver", "com.mysql.jdbc.Driver")); dataSource.setUrl(conf.getProperty("datasource_url")); jdbc = new JdbcTemplate(dataSource); diff --git a/juick-rss/build.gradle b/juick-rss/build.gradle index 19a128e3..87f13e50 100644 --- a/juick-rss/build.gradle +++ b/juick-rss/build.gradle @@ -10,6 +10,7 @@ dependencies { compile project(':juick-core') providedCompile 'javax.servlet:javax.servlet-api:3.1.0' testCompile 'junit:junit:4.12' + compile 'org.apache.commons:commons-dbcp2:2.0' providedRuntime 'mysql:mysql-connector-java:5.1.39' } diff --git a/juick-rss/src/main/java/com/juick/rss/Main.java b/juick-rss/src/main/java/com/juick/rss/Main.java index fd4deca3..46e06677 100644 --- a/juick-rss/src/main/java/com/juick/rss/Main.java +++ b/juick-rss/src/main/java/com/juick/rss/Main.java @@ -20,8 +20,8 @@ package com.juick.rss; import com.juick.Message; import com.juick.server.MessagesQueries; import com.juick.server.UserQueries; +import org.apache.commons.dbcp2.BasicDataSource; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.DriverManagerDataSource; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; @@ -52,7 +52,7 @@ public class Main extends HttpServlet { try { Properties conf = new Properties(); conf.load(getServletContext().getResourceAsStream("/WEB-INF/juick.conf")); - DriverManagerDataSource dataSource = new DriverManagerDataSource(); + BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(conf.getProperty("datasource_driver", "com.mysql.jdbc.Driver")); dataSource.setUrl(conf.getProperty("datasource_url")); sql = new JdbcTemplate(dataSource); diff --git a/juick-ws/build.gradle b/juick-ws/build.gradle index 111c0d5d..a46f3b9f 100644 --- a/juick-ws/build.gradle +++ b/juick-ws/build.gradle @@ -16,6 +16,7 @@ dependencies { compile "org.springframework:spring-websocket:${springFrameworkVersion}" compile 'javax.inject:javax.inject:1' compile 'org.apache.httpcomponents:httpclient:4.5.1' + compile 'org.apache.commons:commons-dbcp2:2.0' testCompile 'junit:junit:4.12' providedRuntime 'mysql:mysql-connector-java:5.1.39' } diff --git a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java index fbc6226b..d432b19c 100644 --- a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java +++ b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java @@ -2,17 +2,14 @@ package com.juick.ws.configuration; import com.juick.ws.WebsocketComponent; import com.juick.ws.XMPPConnection; +import org.apache.commons.dbcp2.BasicDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import org.springframework.web.socket.config.annotation.EnableWebSocket; import org.springframework.web.socket.config.annotation.WebSocketConfigurer; @@ -45,7 +42,7 @@ public class WebsocketConfiguration extends WebMvcConfigurationSupport implement } @Bean JdbcTemplate jdbc() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); + BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(env.getProperty("datasource_driver", "com.mysql.jdbc.Driver")); dataSource.setUrl(env.getProperty("datasource_url")); return new JdbcTemplate(dataSource); diff --git a/juick-www/build.gradle b/juick-www/build.gradle index f09abb3a..22d9672e 100644 --- a/juick-www/build.gradle +++ b/juick-www/build.gradle @@ -35,6 +35,7 @@ dependencies { compile 'org.apache.httpcomponents:httpclient:4.5.1' compile 'org.apache.commons:commons-lang3:3.4' compile "org.springframework:spring-jdbc:4.3.1.RELEASE" + compile 'org.apache.commons:commons-dbcp2:2.0' compile 'org.json:json:20151123' testCompile 'junit:junit:4.12' providedCompile 'javax.servlet:javax.servlet-api:3.1.0' diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java index c39c152c..d7ecd0cb 100644 --- a/juick-www/src/main/java/com/juick/www/Main.java +++ b/juick-www/src/main/java/com/juick/www/Main.java @@ -21,8 +21,8 @@ import com.juick.server.UserQueries; import com.juick.xmpp.JID; import com.juick.xmpp.Stream; import com.juick.xmpp.StreamComponent; +import org.apache.commons.dbcp2.BasicDataSource; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.datasource.DriverManagerDataSource; import ru.sape.Sape; import javax.servlet.ServletException; @@ -71,10 +71,10 @@ public class Main extends HttpServlet implements Stream.StreamListener { Properties conf = new Properties(); conf.load(getServletContext().getResourceAsStream("/WEB-INF/juick.conf")); - DriverManagerDataSource dataSource = new DriverManagerDataSource(); + BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(conf.getProperty("datasource_driver", "com.mysql.jdbc.Driver")); dataSource.setUrl(conf.getProperty("datasource_url")); - DriverManagerDataSource dataSourceSearch = new DriverManagerDataSource(); + BasicDataSource dataSourceSearch = new BasicDataSource(); dataSourceSearch.setDriverClassName(conf.getProperty("datasource_driver", "com.mysql.jdbc.Driver")); dataSourceSearch.setUrl(sqlSearchConnStr); sql = new JdbcTemplate(dataSource); diff --git a/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java b/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java index 4fb40e23..57072cee 100644 --- a/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java +++ b/juick-www/src/main/java/com/juick/xmpp/s2s/XMPPComponent.java @@ -8,6 +8,8 @@ import com.juick.xmpp.*; import com.juick.xmpp.extensions.JuickMessage; import com.juick.xmpp.extensions.Nickname; import com.juick.xmpp.extensions.XOOB; +import org.apache.commons.dbcp2.BasicDataSource; +import org.apache.commons.dbcp2.PoolingDataSource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.xmlpull.v1.XmlPullParserException; @@ -184,7 +186,7 @@ public class XMPPComponent implements ServletContextListener, Stream.StreamListe keystorePassword = conf.getProperty("keystore_password"); brokenSSLhosts = Arrays.asList(conf.getProperty("broken_ssl_hosts", "").split(",")); bannedHosts = Arrays.asList(conf.getProperty("banned_hosts", "").split(",")); - DriverManagerDataSource dataSource = new DriverManagerDataSource(); + BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(conf.getProperty("datasource_driver", "com.mysql.jdbc.Driver")); dataSource.setUrl(conf.getProperty("datasource_url")); sql = new JdbcTemplate(dataSource); -- cgit v1.2.3