#Driver
driverClassName=com.mysql.jdbc.Driver
#UrL
url=jdbc:mysql://192.168.111.15:3306/archive_reader
#User name
username=trafficcast
#Password
password=naitou
#The initial number of connections that are created when the pool is started.
initialSize=10
#The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.
maxActive=50
#The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.
maxIdle=20
#The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.
minIdle=5
#The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.
maxWait=60000
#The connection properties that will be sent to our JDBC driver when establishing new connections.
connectionProperties=useUnicode=true;characterEncoding=gbk
#The default auto-commit state of connections created by this pool.
defaultAutoCommit=true
#The default read-only state of connections created by this pool. If not set then the setReadOnly method will not be called.
defaultReadOnly=
#The default TransactionIsolation state of connections created by this pool.
driverClassName=com.mysql.jdbc.Driver
#UrL
url=jdbc:mysql://192.168.111.15:3306/archive_reader
#User name
username=trafficcast
#Password
password=naitou
#The initial number of connections that are created when the pool is started.
initialSize=10
#The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.
maxActive=50
#The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.
maxIdle=20
#The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.
minIdle=5
#The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.
maxWait=60000
#The connection properties that will be sent to our JDBC driver when establishing new connections.
connectionProperties=useUnicode=true;characterEncoding=gbk
#The default auto-commit state of connections created by this pool.
defaultAutoCommit=true
#The default read-only state of connections created by this pool. If not set then the setReadOnly method will not be called.
defaultReadOnly=
#The default TransactionIsolation state of connections created by this pool.
defaultTransactionIsolation=READ_UNCOMMITTED
package com.trafficcast.jdbc;
import java.io.InputStream;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSourceFactory;
public final class JdbcUtils {
//Data source
private static DataSource myDataSource = null;
//Private Constructor
private JdbcUtils() {}
//Init the properties and init the data source.
static {
try {
Properties prop = new Properties();
InputStream is = JdbcUtils.class.getClassLoader().getResourceAsStream("dbcpconfig.properties");
prop.load(is);
myDataSource = BasicDataSourceFactory.createDataSource(prop);
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
/**
* Get the data source
* @return
*/
public static DataSource getDataSource() {
return myDataSource;
}
}