connection pooling work
This commit is contained in:
parent
cb6253a2a5
commit
561ec82250
|
@ -4,6 +4,7 @@ import java.util.Properties;
|
|||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
@ -11,7 +12,6 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.springframework.orm.hibernate3.HibernateTransactionManager;
|
||||
import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
@ -35,7 +35,7 @@ public class PersistenceConfig {
|
|||
public AnnotationSessionFactoryBean sessionFactory() {
|
||||
final AnnotationSessionFactoryBean sessionFactory = new AnnotationSessionFactoryBean();
|
||||
sessionFactory.setDataSource(dataSource());
|
||||
sessionFactory.setPackagesToScan(new String[] { "org.baeldung.spring.persistence.model" });
|
||||
sessionFactory.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
|
||||
sessionFactory.setHibernateProperties(hibernateProperties());
|
||||
|
||||
return sessionFactory;
|
||||
|
@ -43,7 +43,7 @@ public class PersistenceConfig {
|
|||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||
final BasicDataSource dataSource = new BasicDataSource();
|
||||
dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName")));
|
||||
dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url")));
|
||||
dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user")));
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<bean id="dataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
|
||||
<property name="driverClassName" value="${jdbc.driverClassName}" />
|
||||
<property name="url" value="${jdbc.url}" />
|
||||
<property name="username" value="${jdbc.user}" />
|
||||
|
|
|
@ -9,9 +9,9 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
@EnableTransactionManagement
|
||||
@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" })
|
||||
@ImportResource({ "classpath:hibernate4Config.xml" })
|
||||
public class HibernateXmlConfig {
|
||||
public class PersistenceXmlConfig {
|
||||
|
||||
public HibernateXmlConfig() {
|
||||
public PersistenceXmlConfig() {
|
||||
super();
|
||||
}
|
||||
|
Loading…
Reference in New Issue