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

📄 regtest.java

📁 基于strurs架构+servlet+jsp+javabean架构科研管理系统
💻 JAVA
字号:
/*
 * Created on 2008-6-10
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package cn.edu.zucc.research.ejb.bmp.reg;

import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;

import javax.ejb.CreateException;
import javax.ejb.FinderException;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 * @author chenfang
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class RegTest {

    private cn.edu.zucc.research.ejb.bmp.reg.RegHome getHome()
            throws NamingException {
        return (cn.edu.zucc.research.ejb.bmp.reg.RegHome) getContext().lookup(
                cn.edu.zucc.research.ejb.bmp.reg.RegHome.JNDI_NAME);
    }

    private InitialContext getContext() throws NamingException {
        Hashtable props = new Hashtable();

        props.put(InitialContext.INITIAL_CONTEXT_FACTORY,
                "org.jnp.interfaces.NamingContextFactory");
        props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");

        // This establishes the security for authorization/authentication
        // props.put(InitialContext.SECURITY_PRINCIPAL,"username");
        // props.put(InitialContext.SECURITY_CREDENTIALS,"password");

        InitialContext initialContext = new InitialContext(props);
        return initialContext;
    }

    public void testBean() {

        try {
            //cn.edu.zucc.research.ejb.bmp.reg.Reg reg = getHome().create("");
            RegHome home=this.getHome();
            System.out.println("-----create-----");
            Reg re=home.create("20080610134356-1","教室","20080401121212-1","苹果",new Date(),null,null);
            System.out.println("  num  "+re.getResNum()+"  id  "+re.getResId());
            re.setCheckRemark("djir");
            System.out.println("remark  "+re.getCheckRemark());
          /*  System.out.println("-----findByPrimaryKey-----");
            Integer l=new Integer(37);
            Reg r=home.findByPrimaryKey(l);
            System.out.println("  num  "+r.getResNum());
           
            System.out.println("------findAll------");
            Collection c=home.findAll();
            Iterator i=c.iterator();
            while (i.hasNext()) {
                Reg reg = (Reg)i.next();
                System.out.println("  num  "+reg.getResNum()
                        +"  upload  "+reg.getUploadStaff());
             }
                
            System.out.println("-----findByResNum-----");
            List list=(List)home.findByResNum("20080611134325-1");
            r=(Reg)list.get(0);
            System.out.println("  num  "+r.getResNum());
            System.out.println("-----findFeasibility-----");
            c=home.findFeasibility("2008-03-03","2008-09-12");
            i=c.iterator();
            while (i.hasNext()) {
                Reg reg = (Reg)i.next();
                System.out.println("  num  "+reg.getResNum()
                        +"  upload  "+reg.getUploadStaff());
             }
            
            System.out.println("-----findNotChecked-----");
            c=home.findNotChecked();
            i=c.iterator();
            while (i.hasNext()) {
                Reg reg = (Reg)i.next();
                System.out.println("  num  "+reg.getResNum()
                        +"  upload  "+reg.getUploadStaff());
             }
            System.out.println("-----findChecked-----");
            c=home.findChecked();
            i=c.iterator();
            while (i.hasNext()) {
                Reg reg = (Reg)i.next();
                System.out.println("  num  "+reg.getResNum()
                        +"  upload  "+reg.getUploadStaff());
             }
            System.out.println("-----findBySeaName-----");
            c=home.findBySeaName("resName","教","u1");
            i=c.iterator();
            while (i.hasNext()) {
                Reg reg = (Reg)i.next();
                System.out.println("  num  "+reg.getResNum()
                        +"  upload  "+reg.getUploadStaff()+"  name "+reg.getResName());
             }
            
            System.out.println("-----findBySeaNum-----");
            c=home.findBySeaNum("resNum","08","u1");
            i=c.iterator();
            while (i.hasNext()) {
                Reg reg = (Reg)i.next();
                System.out.println("  num  "+reg.getResNum()
                        +"  upload  "+reg.getUploadStaff());
             }
            */
            //--------------------------------------
            //This is the place you make your calls.
            //System.out.println(myBean.callYourMethod());

        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (NamingException e) {
            e.printStackTrace();
        } catch (CreateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        RegTest test = new RegTest();
        test.testBean();

    }
}

⌨️ 快捷键说明

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