Obtain the Connection
from the DataSource
bean.
You can access the dataSource by using Spring dependency injection to inject it into your bean, or by accessing ApplicationContext
statically:
DataSource ds = (DataSource)ApplicationContextProvider.getApplicationContext().getBean("dataSource");
Connection c = ds.getConnection();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…