|
|
@ -18,13 +18,11 @@ package com.fr.third.alibaba.druid.support.hibernate; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Properties; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.third.alibaba.druid.pool.DruidDataSource; |
|
|
|
import com.fr.third.alibaba.druid.pool.DruidDataSource; |
|
|
|
import com.fr.third.alibaba.druid.pool.DruidDataSourceFactory; |
|
|
|
import com.fr.third.alibaba.druid.pool.DruidDataSourceFactory; |
|
|
|
import com.fr.third.org.hibernate.HibernateException; |
|
|
|
|
|
|
|
import com.fr.third.org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; |
|
|
|
import com.fr.third.org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; |
|
|
|
import com.fr.third.org.hibernate.exception.spi.Configurable; |
|
|
|
import com.fr.third.org.hibernate.service.spi.Configurable; |
|
|
|
import com.fr.third.org.hibernate.service.spi.Stoppable; |
|
|
|
import com.fr.third.org.hibernate.service.spi.Stoppable; |
|
|
|
|
|
|
|
|
|
|
|
public class DruidConnectionProvider implements ConnectionProvider, Configurable, Stoppable { |
|
|
|
public class DruidConnectionProvider implements ConnectionProvider, Configurable, Stoppable { |
|
|
@ -33,7 +31,7 @@ public class DruidConnectionProvider implements ConnectionProvider, Configurable |
|
|
|
|
|
|
|
|
|
|
|
private DruidDataSource dataSource; |
|
|
|
private DruidDataSource dataSource; |
|
|
|
|
|
|
|
|
|
|
|
public DruidConnectionProvider(){ |
|
|
|
public DruidConnectionProvider() { |
|
|
|
dataSource = new DruidDataSource(); |
|
|
|
dataSource = new DruidDataSource(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -64,7 +62,7 @@ public class DruidConnectionProvider implements ConnectionProvider, Configurable |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("rawtypes") |
|
|
|
@SuppressWarnings("rawtypes") |
|
|
|
//@Override
|
|
|
|
@Override |
|
|
|
public void configure(Map configurationValues) { |
|
|
|
public void configure(Map configurationValues) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
DruidDataSourceFactory.config(dataSource, configurationValues); |
|
|
|
DruidDataSourceFactory.config(dataSource, configurationValues); |
|
|
@ -78,12 +76,4 @@ public class DruidConnectionProvider implements ConnectionProvider, Configurable |
|
|
|
dataSource.close(); |
|
|
|
dataSource.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void configure(Properties properties) throws HibernateException { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
DruidDataSourceFactory.config(dataSource, properties); |
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException("config error", e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|