I am using "com.mchange.v2.c3p0.ComboPooledDataSource" in my standalone java database loader application. Upon initializing data connection it print out connection information to the console windows in eclipse. It also include database username & password related information.
Db used is MariaDB.
"Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@b1a58a3 [connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@7a4f0f29"
How can i prevent it to show this message to the console. The content is print to the console after this line of code
myConn = DataSource.getInstance().getConnection();
Implementation :
public class DataSource {
private static DataSource datasource;
private ComboPooledDataSource cpds;
Properties prop = new Properties();
InputStream input = null;
private DataSource() throws IOException, SQLException, PropertyVetoException {
input = new FileInputStream("config.properties");
prop.load(input);
cpds = new ComboPooledDataSource();
cpds.setDriverClass(prop.getProperty("driverclass")); //loads the jdbc driver
cpds.setJdbcUrl(prop.getProperty("database"));
cpds.setUser(prop.getProperty("dbuser"));
cpds.setPassword(prop.getProperty("dbpassword"));
cpds.setMinPoolSize(5);
cpds.setAcquireIncrement(5);
cpds.setMaxPoolSize(20);
cpds.setMaxStatements(180);
}
public static DataSource getInstance() throws IOException, SQLException, PropertyVetoException {
if (datasource == null) {
datasource = new DataSource();
return datasource;
} else {
return datasource;
}
}
public Connection getConnection() throws SQLException {
return this.cpds.getConnection();
}
}
I read the config.properties file where i store the database name and crdentials details.
I am calling the connection pool from my main class like this,
myConn = DataSource.getInstance().getConnection();
myConn.setAutoCommit(false);
Soon after this line is executed , i see an entry in the console mentioning details about the connection pool including database name , username and password details. I am not using log4j for connection pooling , it is being used only for application level logging.