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

📄 dbdao.java

📁 intra_mart是日本NDD公司开发的著名企业应用解决方案中间件。集成了J2ee服务器
💻 JAVA
字号:
/*
 * DBDAO.java
 *
 * Created on 2001/11/22, 15:27
 */

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

import java.sql.Connection;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * 僨乕僞儀乕僗偵摿壔偟偨DAO偱偡丅
 *
 * @author INTRAMART
 * @version 1.0
 */
public abstract class DBDAO implements DAO {

    /** 僨乕僞僐僱僋僞 */
    private DataConnector connector;

    /** 儕僜乕僗 */
    private String resource;

    /** 僐僱僋僔儑儞 */
    private Connection connection;

    /** 僨僼僅儖僩偺僐儞僗僩儔僋僞 */
    public DBDAO() {
        super();
        this.connector = null;
        this.resource = null;
        this.connection = null;
    }

    /**
     * 僨乕僞儕僜乕僗偵愙懕偡傞帪偺忣曬傪愝掕偟傑偡丅
     *
     * @param connector 僨乕僞僐僱僋僞
     * @param resource 儕僜乕僗
     * @param key 僉乕
     * @param connect 愙懕忣曬
     * @throws DataConnectException 愙懕偵幐攕
     */
    public void setConnectInfo(DataConnector connector, String resource, String key, String connect) throws DataConnectException {
        if (connector == null) {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.data.i18n").getString("DBDAO.DataConnectorRequired");
            } catch (MissingResourceException e) {
            }
            throw new DataConnectException(message);
        }
        if (resource == null) {
            String message = null;
            try {
                message = ResourceBundle.getBundle("jp.co.intra_mart.framework.base.data.i18n").getString("DBDAO.ResourceRequired");
            } catch (MissingResourceException e) {
            }
            throw new DataConnectException(message);
        }
        this.connector = connector;
        this.resource = resource;
    }

    /**
     * 偙偺DAO偵娭楢偯偗傜傟偨僐僱僋僔儑儞傪庢摼偟傑偡丅
     *
     * @return 僐僱僋僔儑儞
     * @throws DataConnectException 僐僱僋僔儑儞偺庢摼偵幐攕
     * @throws DataPropertyException 僨乕僞僾儘僷僥傿偺庢摼偵幐攕
     */
    protected Connection getConnection() throws DataConnectException, DataPropertyException {
        if (this.connection == null) {
            this.connection = ((DBConnector)this.connector).getConnection(this.resource);
        }

        return this.connection;
    }
}

⌨️ 快捷键说明

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