Package net.sourceforge.jdbclogger.demo

Source Code of net.sourceforge.jdbclogger.demo.JdbcLoggerSpringDemo

/**
*
*/
package net.sourceforge.jdbclogger.demo;

import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
* @author Catalin Kormos (latest modification by $Author: catalean $)
* @version $Revision: 121 $ $Date: 2007-09-18 04:39:03 +0800 (周二, 2007-09-18) $
*/
public class JdbcLoggerSpringDemo extends AbstractJdbcLoggerDemo {

  private static final String SPRING_CONFIG_FILE_PATH = "classpath*:net/sourceforge/jdbclogger/demo/jdbclogger.spring.xml";
  private static final String DATA_SOURCE_BEAN_NAME = "dataSource";
 
  private ApplicationContext applicationContext;
 
  public JdbcLoggerSpringDemo() {
    applicationContext = new ClassPathXmlApplicationContext(SPRING_CONFIG_FILE_PATH);
  }
 
  /* (non-Javadoc)
   * @see net.sourceforge.jdbclogger.demo.AbstractJdbcLoggerDemo#getConnection()
   */
  @Override
  protected Connection getConnection() throws SQLException {
    DataSource dataSource = (DataSource)applicationContext.getBean(DATA_SOURCE_BEAN_NAME);
    return dataSource.getConnection();
  }

  /**
   * @param args
   */
  public static void main(String[] args) {
    JdbcLoggerSpringDemo demo = new JdbcLoggerSpringDemo();
    demo.executeJdbcStatements();
  }
}
TOP

Related Classes of net.sourceforge.jdbclogger.demo.JdbcLoggerSpringDemo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.