Untitled

 avatar
unknown
plain_text
5 months ago
1.2 kB
2
Indexable
package com.taiwanlife.tcavmgt.config;

import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400ConnectionPool;
import com.taiwanlife.tcavmgt.properties.AS400Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class As400RpgConfig
{
	@Autowired
	AS400Properties as400Properties;

	@Bean(name = "as400ConnectionPool")
	public AS400ConnectionPool as400ConnectionPool() throws Exception
	{
		AS400ConnectionPool connPool = new AS400ConnectionPool();
		connPool.setMaxConnections(as400Properties.getMaxConn());
		connPool.setMaxLifetime(as400Properties.getMaxLifetime());
		connPool.setCleanupInterval(as400Properties.getCleanupInterval());
		connPool.setMaxInactivity(as400Properties.getMaxInactivity());
		connPool.setMaxUseTime(as400Properties.getMaxUseTime());
		try
		{
			connPool.fill(as400Properties.getServer(), as400Properties.getUser(), as400Properties.getPassword(), AS400.COMMAND, as400Properties.getInitConn());
		}
		catch (Exception e)
		{
			connPool = null;
		}
		return connPool;
	}
}
Editor is loading...
Leave a Comment