aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-06-02 12:50:17 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-06-02 12:50:17 +1200
commitf0750a4b89088f05af6f561201b43ceeb407bd35 (patch)
tree18bb38b08a43e25a98f5178afbee5074ec3b7d3b /src/org/traccar/database
parentd2c85b59bde4729d027ef1bb6e874d1fd1a02c68 (diff)
parent27770369091fd063503ccea4cca6a815a03ca79f (diff)
downloadtrackermap-server-f0750a4b89088f05af6f561201b43ceeb407bd35.tar.gz
trackermap-server-f0750a4b89088f05af6f561201b43ceeb407bd35.tar.bz2
trackermap-server-f0750a4b89088f05af6f561201b43ceeb407bd35.zip
Replace c3p0 with hikari
Replace c3p0 with hikari
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/DataManager.java64
1 files changed, 35 insertions, 29 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index dffb8937c..ad7c4478b 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -15,7 +15,25 @@
*/
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.Calendar;
+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,35 +41,21 @@ 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;
import org.traccar.model.Device;
-import org.traccar.model.Event;
import org.traccar.model.DevicePermission;
+import org.traccar.model.Event;
import org.traccar.model.Group;
import org.traccar.model.GroupPermission;
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.Calendar;
-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 {
@@ -108,19 +112,21 @@ 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 hikariConfig = new HikariConfig();
+ hikariConfig.setDriverClassName(config.getString("database.driver"));
+ hikariConfig.setJdbcUrl(config.getString("database.url"));
+ hikariConfig.setUsername(config.getString("database.user"));
+ hikariConfig.setPassword(config.getString("database.password"));
+ hikariConfig.setConnectionInitSql("SELECT 1 FROM DUAL");
+ hikariConfig.setIdleTimeout(600000);
+
int maxPoolSize = config.getInteger("database.maxPoolSize");
+
if (maxPoolSize != 0) {
- ds.setMaxPoolSize(maxPoolSize);
+ hikariConfig.setMaximumPoolSize(maxPoolSize);
}
- dataSource = ds;
+
+ dataSource = new HikariDataSource(hikariConfig);
}
}