diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-10-10 08:59:32 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-10-10 10:23:33 +0200 |
commit | ccf4726ae0530695bd55903a989bbd6afae1dd5c (patch) | |
tree | 15fe0521eeaa7162f38efb7851047eecdf130496 | |
parent | a2e88db394ecb5ceba9c01e87612de7e2c5e5cf1 (diff) | |
download | sonarqube-ccf4726ae0530695bd55903a989bbd6afae1dd5c.tar.gz sonarqube-ccf4726ae0530695bd55903a989bbd6afae1dd5c.zip |
SONAR-5605 MySQL: configure driver to use server side cursor and not client side cursor
4 files changed, 5 insertions, 9 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java index b49fc88edee..d0724aaa813 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java @@ -21,7 +21,6 @@ package org.sonar.server.db.migrations; import org.apache.commons.dbutils.DbUtils; import org.sonar.core.persistence.Database; -import org.sonar.core.persistence.dialect.MySql; import java.sql.Connection; import java.sql.PreparedStatement; @@ -83,11 +82,7 @@ class SelectImpl extends BaseSqlStatement<Select> implements Select { static SelectImpl create(Database db, Connection connection, String sql) throws SQLException { PreparedStatement pstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); - if (db.getDialect().getId().equals(MySql.ID)) { - pstmt.setFetchSize(Integer.MIN_VALUE); - } else { - pstmt.setFetchSize(1000); - } + pstmt.setFetchSize(1000); return new SelectImpl(pstmt); } } diff --git a/sonar-application/src/main/assembly/conf/sonar.properties b/sonar-application/src/main/assembly/conf/sonar.properties index e3477959f1b..0c70358e1c1 100644 --- a/sonar-application/src/main/assembly/conf/sonar.properties +++ b/sonar-application/src/main/assembly/conf/sonar.properties @@ -28,7 +28,7 @@ #----- MySQL 5.x -#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance +#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useCursorFetch=true #----- Oracle 10g/11g diff --git a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java index 20e32cacd02..2ce07111978 100644 --- a/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java +++ b/sonar-application/src/main/java/org/sonar/application/JdbcSettings.java @@ -98,6 +98,7 @@ public class JdbcSettings { if (Provider.mysql.equals(provider)) { checkRequiredParameter(url, "useUnicode=true"); checkRequiredParameter(url, "characterEncoding=utf8"); + checkRequiredParameter(url, "useCursorFetch=true"); checkRecommendedParameter(url, "rewriteBatchedStatements=true"); checkRecommendedParameter(url, "useConfigs=maxPerformance"); } diff --git a/sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java b/sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java index ad603c4e453..e1cdeffa94e 100644 --- a/sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java +++ b/sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java @@ -64,11 +64,11 @@ public class JdbcSettingsTest { // minimal -> ok settings.checkUrlParameters(JdbcSettings.Provider.mysql, - "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8"); + "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&useCursorFetch=true"); // full -> ok settings.checkUrlParameters(JdbcSettings.Provider.mysql, - "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance"); + "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useCursorFetch=true"); // missing required -> ko try { |