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

📄 operatordao.java

📁 功能完善的java开发框架
💻 JAVA
字号:
/*
 * Copyright 2003-2005 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package com.jdon.framework.test.dao;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import org.apache.log4j.Logger;

import com.jdon.model.query.JdbcTemp;
import com.jdon.servicelocator.ServiceLocatorException;
import com.jdon.servicelocator.ejb.ServiceLocator;

/**
 * @author <a href="mailto:banqJdon<AT>jdon.com">banq</a>
 *
 */

public class OperatorDao {

    private final static Logger logger = Logger.getLogger(OperatorDao.class);

    private DataSource dataSource ;
    
    private JdbcTemp jdbcTemp;
    

    public OperatorDao(String jndiname) {
        try {
            ServiceLocator sl = new ServiceLocator();
            dataSource = (DataSource) sl.getDataSource(jndiname);
            jdbcTemp = new JdbcTemp(dataSource);
        } catch (ServiceLocatorException slx) {
            logger.error(slx);
        }
    }
    
    public String getOperator(String userName) {
        String GET_FIELD = "SELECT a.rolename, 'Roles' FROM T_ROLE a join t_user_role b on a.roleid = b.roleid join t_user c on  b.userid = c.userid  where c.username=?";
        List queryParams = new ArrayList();
        queryParams.add(userName);

        String ret = null;

        try {
            List list = jdbcTemp.queryMultiObject(queryParams,
                    GET_FIELD);
            Iterator iter = list.iterator();
            if (iter.hasNext()) {
                Map map = (Map) iter.next();
                ret = ((String) map.get("rolename"));
            }
        } catch (Exception se) {
        }
        return ret;
    }

        
}

⌨️ 快捷键说明

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