1 16 package scriptella.driver.spring; 17 18 import org.springframework.beans.factory.BeanFactory; 19 import scriptella.jdbc.GenericDriver; 20 21 import javax.sql.DataSource ; 22 import java.sql.SQLException ; 23 import java.util.Properties ; 24 25 36 public class Driver extends GenericDriver { 37 @Override 38 protected java.sql.Connection getConnection(String url, Properties props) throws SQLException { 39 if (url == null) { 40 throw new SpringProviderException("Name of the spring bean must be specified in an url attribute of connection element."); 41 } 42 try { 43 BeanFactory beanFactory = EtlExecutorBean.getContextBeanFactory(); 44 DataSource ds = (DataSource ) beanFactory.getBean(url); 45 return ds.getConnection(); 46 } catch (Exception e) { 47 throw new SpringProviderException("A problem occured while trying to lookup a datasource with name " + url, e); 48 } 49 50 } 51 52 53 54 55 } 56 | Popular Tags |