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

📄 detailtest.java

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

import java.rmi.RemoteException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;

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

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

    private cn.edu.zucc.research.ejb.cmp.detail.DetailHome getHome()
            throws NamingException {
        return (cn.edu.zucc.research.ejb.cmp.detail.DetailHome) getContext()
                .lookup(
                        cn.edu.zucc.research.ejb.cmp.detail.DetailHome.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.cmp.detail.Detail myBean = getHome()
                    //.create();
        	//String date=df.format(new Date());
            DetailHome home=getHome();
            /*System.out.println("-----create-----");
            Detail de=home.create("20080611140223-1","20080611134325-1","djklds",
                    "2008-10-12","reger","u1",new Double(25.0),"null",new   Timestamp(System.currentTimeMillis()),null);
            System.out.println("id"+de.getResDeId()+"  num "+de.getResNum());*/
            System.out.println("-----findByPrimaryKey-----");
            Detail  dee=home.findByPrimaryKey("20080611175828-1");
            System.out.println("  num  "+dee.getResNum()
                    +"  respon  "+dee.getResponsible());
            System.out.println("-----findByResNum----");
            Detail dde=home.findByResNum("20080611134325-1");
            System.out.println("  num  "+dde.getResNum()
                    +"  respon  "+dde.getResponsible());
           System.out.println("------findAll------");
            Collection c=home.findAll(); System.out.println(c.size());
           Iterator i=c.iterator();
          
           while(i.hasNext()){
               Detail det=(Detail)i.next();
               System.out.println(c.size()+"  num  "+det.getResNum()
                       +"  respon  "+det.getResponsible());
           }

            
            
            //--------------------------------------
            //This is the place you make your calls.
            //System.out.println(myBean.callYourMethod());

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

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

    }
}

⌨️ 快捷键说明

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