NutzCN Logo
问答 junt test方法里的事务完后DEBUG STACK TRACE for PoolBackedDataSource.close().
发布于 2835天前 作者 milixiang 2362 次浏览 复制 上一个帖子 下一个帖子
标签:

spring 注入的dao

Trans.exec(new Molecule<Object>(){

			public void run() {
				try {
					for(int i=1;i<=lastRowNum;i++){ //循环每一行开始导入
						Unit unit = new Unit();
						XSSFRow row = sheet0.getRow(i);
						XSSFCell c_address = row.getCell(0);
						String address = ExcelUtil.getValue(c_address);
						
						if(StringUtils.isBlank(address))
							continue;
						
						//address = 延安西路1328弄   7 -  16B
						Pattern p=Pattern.compile("\\d*-.*"); 
					    Matcher m=p.matcher(address); 
					    m.find();
					    String pStr = m.group();
					    String projectAddress = address.substring(0, address.indexOf(pStr));
					    unit.setProjectId(projectId);
					    if(null == projectAddressMap.getInt(projectAddress)){
					    	ProjectAddress pa = new ProjectAddress();
					    	pa.setProjectId(projectId);
					    	pa.setName(projectAddress);
					    	pa = dao.insert(pa);
					    	projectAddressMap.put(projectAddress, pa.getId());
					    }
					    unit.setUnitAddressId(projectAddressMap.getInt(projectAddress));

					    String[] temp = pStr.split("-");
					    
					    //插入building后获取buildingId 放到unit中
					    Building building = new Building();
					    building.setBuildingName(temp[0]);
					    building.setAddressId(projectAddressMap.getInt(projectAddress));
					    Building fetch = dao.fetch(Building.class,Cnd.where("buildingName", "=", temp[0]).and("addressId", "=", projectAddressMap.getInt(projectAddress)));
						if(fetch == null)
					    	building = dao.insert(building);
					    else
					    	building = fetch;
					    unit.setUnitBuildingId(building.getId());
					    
					    unit.setUnitName(temp[1]);
					    unit.setBuildingArea(Float.parseFloat(
					    		ExcelUtil.getValue(
					    				row.getCell(3)
					    				)));
					    
					    unit.setRoomPropertyId(roomPropertyMap.getInt(ExcelUtil.getValue(
					    				row.getCell(1)
					    				)));
					    
					    unit.setPropertyTypeId(propertyTypeMap.getInt(ExcelUtil.getValue(
								row.getCell(2)
								)));
					    
					    unit.setContactName(ExcelUtil.getValue(row.getCell(5)));
					    unit.setContactPhone(ExcelUtil.getValue(row.getCell(6)));
					    unit.setResidentsPopulation(StringUtils.isNoneBlank(ExcelUtil.getValue(row.getCell(9)))?(Integer.parseInt(ExcelUtil.getValue(row.getCell(9)))):null);
					    dao.insert(unit);
					}
				} catch (Exception e) {
					e.printStackTrace();
					throw new DaoException("e");
				}
			}
		});

调试看着是循环正常结束了 但是报这个错误

java.lang.Exception: DEBUG STACK TRACE for PoolBackedDataSource.close().
	at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.close(AbstractPoolBackedDataSource.java:417)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:353)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:276)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:972)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:979)
	at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1000)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:976)
	at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:895)
4 回复

没使用SpringDaoRunner?

untitled1_png untitled2_png untitled3_png untitled4_png


<bean id="springDaoRunner" class="org.nutz.integration.spring.SpringDaoRunner"></bean> <bean id="nutzDao" class="org.nutz.dao.impl.NutDao"> <property name="dataSource" ref="dataSource"></property> <property name="runner" ref="springDaoRunner" /> </bean>

用了啊

@milixiang 那就不知道了

来自炫酷的 NutzCN

知道了

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close" >

destroy-method="close" 是因为这个删掉就好了 虽然不知道为什么
实际上没影响 事务提交了 用的navcat 默认值只显示了1000行
看着怎么刷新都没增加新纪录 以为事务回滚了

添加回复
请先登陆
回到顶部