businesslogic.java

来自「第一步:将MyBookApp目录复制到C:下。 第二步:将book.mdb复制」· Java 代码 · 共 153 行

JAVA
153
字号
/* * BusinessLogic.java * * Created on 2003年5月9日, 下午9:07 *//** * * @author  administrator */import java.util.*;import java.math.*;import javax.naming.Context;import javax.naming.InitialContext;import javax.rmi.PortableRemoteObject;class BusinessLogic {        private BookSessionHome bookSessionHome;    private BookSession bookSession;        /** Creates a new instance of BusinessLogic */    public BusinessLogic()     {        try {           Context initial = new InitialContext();           Object objref = initial.lookup("java:comp/env/ejb/SimpleBookSession");           bookSessionHome =                (BookSessionHome)PortableRemoteObject.narrow(objref,                                             BookSessionHome.class);                      bookSession = bookSessionHome.create();                   }catch (Exception ex) {           System.err.println("Caught an exception." );           ex.printStackTrace();        }                            }        public Vector getAllBook(String str)    {        Vector v=new Vector();        try {                                v=(Vector)bookSession.getAllBook(str);                   }catch (Exception ex) {           System.err.println("Caught an exception." );           ex.printStackTrace();       }                return v;    }        public Vector getQueryBook(String bookName)    {        Vector v=new Vector();        try {                                v=bookSession.getQueryBook(bookName);                   }catch (Exception ex) {           System.err.println("Caught an exception." );           ex.printStackTrace();       }                return v;            }        public Vector getBorrowedBook(String str)    {        Vector v=new Vector();        try {                                v=bookSession.getBorrowedBook(str);                   }catch (Exception ex) {           System.err.println("Caught an exception." );           ex.printStackTrace();       }                return v;    }        public Vector getQueryBorrowedBook(String str)    {        Vector v=new Vector();        try {                                v=bookSession.getQueryBorrowedBook(str);                   }catch (Exception ex) {           System.err.println("Caught an exception." );           ex.printStackTrace();       }                return v;    }        public int borrowBook(String bookId)    {        int result=0;        try {                                result=bookSession.borrowBook(bookId);                   }catch (Exception ex) {           System.err.println("Caught an exception." );           ex.printStackTrace();       }               return result;    }        public int returnBook(String borrowId)    {        int result=0;        try {                                result=bookSession.returnBook(borrowId);                   }catch (Exception ex) {           System.err.println("Caught an exception." );           ex.printStackTrace();       }               return result;            }        public int checkUser(String userName,String userPassword)    {        int result=0;        try {                                result=bookSession.checkUser(userName, userPassword);                   }catch (Exception ex) {           System.err.println("Caught an exception." );           ex.printStackTrace();       }               return result;    }    }

⌨️ 快捷键说明

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