⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logingroupdbconnector.java

📁 intra_mart是日本NDD公司开发的著名企业应用解决方案中间件。集成了J2ee服务器
💻 JAVA
字号:
/*
 * LoginGroupDBConnector.java
 *
 * Created on 2005/01/28, 16:09
 */

package jp.co.intra_mart.framework.base.data;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import javax.naming.NamingException;

import jp.co.intra_mart.foundation.database.DatabaseManager;
import jp.co.intra_mart.foundation.security.exception.AccessSecurityException;
import jp.co.intra_mart.foundation.security.exception.NotExistException;
import jp.co.intra_mart.framework.system.log.LogConstant;
import jp.co.intra_mart.framework.system.log.LogManager;

/**
 * 僀儞僩儔儅乕僩偱愝掕偝傟偰偄傞DB僐僱僋僔儑儞偱偡丅<BR>
 * 儘僌僀儞僌儖乕僾ID偐傜僐僱僋僔儑儞傪庢摼偟傑偡丅
 *
 * @author INTRAMART
 * @version 1.0
 * @since 5.0
 */
public class LoginGroupDBConnector extends DataConnector {

	/**
     * 儕僜乕僗堦棗
     */
    protected Map connections;

    /**
     * LoginGroupDBConnector傪怴婯偵惗惉偟傑偡丅
     */
    public LoginGroupDBConnector() {
        super();
        this.connections = new HashMap();
    }

    /**
     * 僐儈僢僩偟傑偡丅
     * 幚嵺偵偼偙偺僋儔僗偱偼偙偺儊僜僢僪偼壗傕偟傑偣傫丅
     *
     * @throws DataConnectException 僐儈僢僩偵幐攕
     */
	public void commit() throws DataConnectException {
	}

    /**
     * 儘乕儖僶僢僋偟傑偡丅
     * 幚嵺偵偼偙偺僋儔僗偱偼偙偺儊僜僢僪偼壗傕偟傑偣傫丅
     *
     * @throws DataConnectException 儘乕儖僶僢僋偵幐攕
     */	public void rollback() throws DataConnectException {
	}

    /**
     * 僨乕僞僗僩傾偺帒尮傪夝曻偟傑偡丅
     *
     * @throws DataConnectException 帒尮奐曻偵幐攕
     */
    public void release() throws DataConnectException {
        Iterator connections;
        Connection connection;
        DataConnectException exception = null;

        if (this.connections != null) {
            connections = this.connections.values().iterator();
            while (connections.hasNext()) {
                connection = (Connection)connections.next();
                try {
                    connection.close();
                } catch (Exception e) {
                    LogManager.getLogManager().getLogAgent().sendMessage(
                        DataSourceConnector.class.getName(),
                        LogConstant.LEVEL_ERROR,
                        DataManager.LOG_HEAD + e.getMessage(),
                        e);
                    String message = null;
                    try {
                        message =
                            ResourceBundle.getBundle(
                                "jp.co.intra_mart.framework.base.data.i18n")
                                    .getString(
                                "Common.FailedToReleaseResource");
                    } catch (MissingResourceException ex) {
                    }
                    exception = new DataConnectException(message, e);
                }
            }
        }

        if (exception != null) {
            throw exception;
        }
    }
    /**
     * 僨乕僞儀乕僗傊偺僐僱僋僔儑儞傪庢摼偟傑偡丅
     *
     * @param connect 愙懕忣曬
     * @return 僨乕僞儀乕僗傊偺僐僱僋僔儑儞
     * @throws DataPropertyException 僨乕僞儀乕僗傊偺僐僱僋僔儑儞偺庢摼偵幐攕
     * @throws DataConnectException 僨乕僞儀乕僗傊偺愙懕偵幐攕
     */
    public Connection getConnection(String connect)
        throws DataPropertyException, DataConnectException {
        return (Connection)getResource("", connect, "");
    }

    /**
     * 儕僜乕僗傪庢摼偟傑偡丅
     *
     * @param key 僉乕
     * @param connect 愙懕忣曬
     * @param resource 儕僜乕僗柤
     * @return 儕僜乕僗
     * @throws DataPropertyException 儕僜乕僗偺庢摼偵幐攕
     * @throws DataConnectException 愙懕偵幐攕
     */
    protected Object getResource(String key, String connect, String resource)
    throws DataConnectException {
        Object obj = this.connections.get(connect);
        if (obj == null) {
            obj = putConnection(connect);
        }
        return obj;
    }

	/**
	 * 儘僌僀儞僌儖乕僾ID偐傜僐僱僋僔儑儞傪庢摼偟傑偡丅
	 * 
	 * @param connect 愙懕忣曬
	 * @return
	 */
	private Connection putConnection(String connect) throws DataConnectException{
        Connection connection = null;
        
        try {
        	DatabaseManager manager = DatabaseManager.getInstance();
			connection = manager.getLoginGroupConnection(connect);
            this.connections.put(connect, connection);
		} catch (NotExistException e) {
			throw new DataConnectException(e.getMessage(), e);
		} catch (NamingException e) {
			throw new DataConnectException(e.getMessage(), e);
		} catch (SQLException e) {
			throw new DataConnectException(e.getMessage(), e);
		} catch (AccessSecurityException e) {
			throw new DataConnectException(e.getMessage(), e);
		}
		
		return connection;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -