• 大小: 35KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-07
  • 语言: 其他
  • 标签:

资源简介

这个是已经实现了动态切换数据源的,大家看看,很有用的

资源截图

代码片段和文件信息

/**
 * 
 */
package com.htxx.demo;

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

import com.htxx.demo.model.Department;
import com.htxx.demo1.model.Users;
import com.htxx.service.dao.GenericDao;
import com.htxx.service.dao.SpObserver;

/**
 * @author FanGang
 *
 */
public class MultiSessionFactoryTest {

private GenericDao dao;

/**
 * @return the dao
 */
public GenericDao getDao() {
return dao;
}

/**
 * @param dao the dao to set
 */
public void setDao(GenericDao dao) {
this.dao = dao;
}

public static void main(String[] args) {
ApplicationContext ac = new FileSystemxmlApplicationContext(“classpath:ApplicationContext-sessionFactory.xml“);

MultiSessionFactoryTest test = (MultiSessionFactoryTest)ac.getBean(“multiSessionFactoryTest“);
SpObserver.putSp(“sessionFactory2“);
Users users = new Users(“test““test“);
test.getDao().insert(users);
SpObserver.putSp(“sessionFactory1“);
Department department = new Department(“dep1“);
test.getDao().insert(department);
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    .......      3072  2007-06-16 23:02  example\MultiSessionFactoryExample\ApplicationContext-sessionFactory.xml

    .......      1402  2007-05-10 10:30  example\MultiSessionFactoryExample\com\htxx\demo\model\AbstractDepartment.java

    .......       967  2007-05-11 17:24  example\MultiSessionFactoryExample\com\htxx\demo\model\Department.hbm.xml

    .......       579  2007-05-10 10:58  example\MultiSessionFactoryExample\com\htxx\demo\model\Department.java

    .......      1145  2007-06-16 23:02  example\MultiSessionFactoryExample\com\htxx\demo\MultiSessionFactoryTest.java

    .......      1097  2007-06-15 19:31  example\MultiSessionFactoryExample\com\htxx\demo1\model\AbstractUsers.java

    .......       793  2007-06-15 19:31  example\MultiSessionFactoryExample\com\htxx\demo1\model\Users.hbm.xml

    .......       455  2007-06-15 19:31  example\MultiSessionFactoryExample\com\htxx\demo1\model\Users.java

    .......      4708  2007-05-10 15:41  example\MultiSessionFactoryExample\com\htxx\service\dao\BasicDao.java

    .......      2414  2007-02-13 10:00  example\MultiSessionFactoryExample\com\htxx\service\dao\Condition.java

    .......       305  2007-02-15 11:58  example\MultiSessionFactoryExample\com\htxx\service\dao\DaoException.java

    .......      1675  2007-05-09 10:02  example\MultiSessionFactoryExample\com\htxx\service\dao\DaoSupport.java

    .......      7284  2007-05-10 15:37  example\MultiSessionFactoryExample\com\htxx\service\dao\DaoSupportHibernate3Imp.java

    .......      7674  2007-05-09 10:48  example\MultiSessionFactoryExample\com\htxx\service\dao\DaoSupportHibernateImp.java

    .......      1535  2007-05-09 15:24  example\MultiSessionFactoryExample\com\htxx\service\dao\DaoUtil.java

    .......      2006  2007-04-27 09:52  example\MultiSessionFactoryExample\com\htxx\service\dao\DynamicLoadBean.java

    .......      2609  2007-05-09 10:45  example\MultiSessionFactoryExample\com\htxx\service\dao\GenericDao.java

    .......      2761  2007-04-09 08:45  example\MultiSessionFactoryExample\com\htxx\service\dao\MultiDataSource.java

    .......      7958  2007-06-16 23:01  example\MultiSessionFactoryExample\com\htxx\service\dao\MultiSessionFactory.java

    .......      3875  2007-03-27 15:39  example\MultiSessionFactoryExample\com\htxx\service\dao\ResultSet.java

    .......       300  2007-04-06 09:04  example\MultiSessionFactoryExample\com\htxx\service\dao\SpObserver.java

    .......       839  2007-04-09 14:32  example\MultiSessionFactoryExample\com\htxx\service\dao\SpringContext.java

    .......       167  2007-03-28 15:05  example\MultiSessionFactoryExample\com\htxx\service\dao\UpdateProxy.java

     文件      19141  2007-06-17 15:42  example\MultiSessionFactoryExample.jar

     文件         66  2007-06-17 15:45  example\ReadMe.txt

     目录          0  2011-04-12 09:45  example\MultiSessionFactoryExample\com\htxx\demo\model

     目录          0  2011-04-12 09:45  example\MultiSessionFactoryExample\com\htxx\demo1\model

     目录          0  2011-04-12 09:45  example\MultiSessionFactoryExample\com\htxx\service\dao

     目录          0  2011-04-12 09:45  example\MultiSessionFactoryExample\com\htxx\demo

     目录          0  2011-04-12 09:45  example\MultiSessionFactoryExample\com\htxx\demo1

............此处省略8个文件信息

评论

共有 条评论

相关资源