aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authordrecchia <danilo@deltatecnologia.com>2016-05-30 22:57:21 -0300
committerdrecchia <danilo@deltatecnologia.com>2016-05-30 22:57:21 -0300
commite91153481a220235130a277d20f724b97fcfd325 (patch)
treeaeaa16ce2481c778011b2a018ade5911c899b901 /src/org/traccar
parent4176894097bb9f3d06ff339e9e845c4969ca6874 (diff)
downloadtraccar-server-e91153481a220235130a277d20f724b97fcfd325.tar.gz
traccar-server-e91153481a220235130a277d20f724b97fcfd325.tar.bz2
traccar-server-e91153481a220235130a277d20f724b97fcfd325.zip
- Replaced connection poll from c3p0 to HikariCP.
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/database/DataManager.java62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index ac3be45ac..898669c21 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -15,7 +15,24 @@
*/
package org.traccar.database;
-import com.mchange.v2.c3p0.ComboPooledDataSource;
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
import liquibase.Contexts;
import liquibase.Liquibase;
import liquibase.database.Database;
@@ -23,6 +40,7 @@ import liquibase.database.DatabaseFactory;
import liquibase.exception.LiquibaseException;
import liquibase.resource.FileSystemResourceAccessor;
import liquibase.resource.ResourceAccessor;
+
import org.traccar.Config;
import org.traccar.Context;
import org.traccar.helper.Log;
@@ -34,22 +52,8 @@ import org.traccar.model.Position;
import org.traccar.model.Server;
import org.traccar.model.User;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-import java.io.File;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
public class DataManager implements IdentityManager {
@@ -106,19 +110,23 @@ public class DataManager implements IdentityManager {
Class.forName(driver);
}
- ComboPooledDataSource ds = new ComboPooledDataSource();
- ds.setDriverClass(config.getString("database.driver"));
- ds.setJdbcUrl(config.getString("database.url"));
- ds.setUser(config.getString("database.user"));
- ds.setPassword(config.getString("database.password"));
- ds.setIdleConnectionTestPeriod(600);
- ds.setTestConnectionOnCheckin(true);
- ds.setMaxStatementsPerConnection(config.getInteger("database.maxStatements"));
+ HikariConfig hConfig = new HikariConfig();
+ hConfig.setDriverClassName( config.getString("database.driver") );
+ hConfig.setJdbcUrl( config.getString("database.url") );
+ hConfig.setUsername( config.getString("database.user") );
+ hConfig.setPassword( config.getString("database.password") );
+ hConfig.setConnectionInitSql( "SELECT 1 FROM DUAL" );
+ hConfig.setIdleTimeout( 600000 ); // milliseconds
+// ds.setIdleConnectionTestPeriod(600);
+// ds.setMaxStatementsPerConnection(config.getInteger("database.maxStatements"));
+
int maxPoolSize = config.getInteger("database.maxPoolSize");
+
if (maxPoolSize != 0) {
- ds.setMaxPoolSize(maxPoolSize);
+ hConfig.setMaximumPoolSize( maxPoolSize );
}
- dataSource = ds;
+
+ dataSource = new HikariDataSource(hConfig);
}
}