01: /**
02: *
03: */package net.sourceforge.jdbclogger.demo;
04:
05: import java.sql.Connection;
06: import java.sql.SQLException;
07:
08: import javax.sql.DataSource;
09:
10: import org.springframework.context.ApplicationContext;
11: import org.springframework.context.support.ClassPathXmlApplicationContext;
12:
13: /**
14: * @author Catalin Kormos (latest modification by $Author: catalean $)
15: * @version $Revision: 121 $ $Date: 2007-09-17 13:39:03 -0700 (Mon, 17 Sep 2007) $
16: */
17: public class JdbcLoggerSpringDemo extends AbstractJdbcLoggerDemo {
18:
19: private static final String SPRING_CONFIG_FILE_PATH = "classpath*:net/sourceforge/jdbclogger/demo/jdbclogger.spring.xml";
20: private static final String DATA_SOURCE_BEAN_NAME = "dataSource";
21:
22: private ApplicationContext applicationContext;
23:
24: public JdbcLoggerSpringDemo() {
25: applicationContext = new ClassPathXmlApplicationContext(
26: SPRING_CONFIG_FILE_PATH);
27: }
28:
29: /* (non-Javadoc)
30: * @see net.sourceforge.jdbclogger.demo.AbstractJdbcLoggerDemo#getConnection()
31: */
32: @Override
33: protected Connection getConnection() throws SQLException {
34: DataSource dataSource = (DataSource) applicationContext
35: .getBean(DATA_SOURCE_BEAN_NAME);
36: return dataSource.getConnection();
37: }
38:
39: /**
40: * @param args
41: */
42: public static void main(String[] args) {
43: JdbcLoggerSpringDemo demo = new JdbcLoggerSpringDemo();
44: demo.executeJdbcStatements();
45: }
46: }
|