
com.jk.data.datasource.impl.JKPlainDataSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jk-framework-data Show documentation
Show all versions of jk-framework-data Show documentation
This contains a set of API's that ease the database programming with Java, in both: JDBC and JPA Persisitnce).
package com.jk.data.datasource.impl;
import java.util.Map;
import java.util.Properties;
import javax.sql.DataSource;
import com.jk.core.jdbc.JKDriverManagerDataSource;
import com.mchange.v2.c3p0.DriverManagerDataSource;
public class JKPlainDataSource extends JKHibernateDataSource {
public static final String[] PROPERTIES_TO_IGNORE= {"c3p0","min_size","max_size","pool_size"};
/**
*
* @param name
* @param properties
*/
public JKPlainDataSource(String name, Properties properties) {
super(name, properties);
}
@Override
protected void processProperty(Properties properties, String key, String value) {
for (String property: PROPERTIES_TO_IGNORE) {
if(key.contains(property)) {
logger.debug("Ignoring property ({})", key);
return;
}
}
super.processProperty(properties, key, value);
}
@Override
protected Map getHibernateExtraConfig() {
Properties prop=new Properties();
//prop.setProperty("hibernate.pool_size", "0");
prop.put("hibernate.connection.datasource", createPlainDataSource());
return prop;
}
/**
* @return
*/
protected DataSource createPlainDataSource() {
logger.info("createPlainDataSource()");
JKDriverManagerDataSource actualDataSource = new JKDriverManagerDataSource();
actualDataSource.setUrl(getDatabaseUrl());
actualDataSource.setUser(getDatabaseUsername());
actualDataSource.setPassword(getDatabasepassword());
logger.info("/createPlainDataSource()");
return actualDataSource;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy