projects-jenz/RaceTimer/racetimer_endpoints/src/main/java/DataMapper/DBCPDataSource2.java

44 lines
1.1 KiB
Java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DataMapper;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.dbcp2.BasicDataSource;
/**
*
* @author install1
*/
public class DBCPDataSource2 {
private static BasicDataSource ds = new BasicDataSource();
static {
try {
ds.setDriver(new com.mysql.cj.jdbc.Driver());
ds.setUrl(settings.forumURL);
ds.setUsername(settings.forumUser);
ds.setPassword(settings.forumPassword);
ds.setMaxTotal(-1);
ds.setMinIdle(5);
ds.setMaxIdle(-1);
ds.setMaxOpenPreparedStatements(100);
} catch (SQLException ex) {
Logger.getLogger(DBCPDataSource.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static Connection getConnection() throws SQLException {
return ds.getConnection();
}
private DBCPDataSource2() {
}
}