How can I get the current Connection object for an Oracle database? I'm using the JDBC module in Spring 3.0.5.
See Question&Answers more detail:osHow can I get the current Connection object for an Oracle database? I'm using the JDBC module in Spring 3.0.5.
See Question&Answers more detail:osObtain 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();