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

📄 buyejb.java

📁 structejbmysql开发工程源码
💻 JAVA
字号:
/*
 * Created on 2007/03/05
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package access.buy;

import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Hashtable;

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

import course.data.ChengJi;
import course.data.KeChengChengJi;
import course.data.buy.Buy;
import course.data.buy.UserInf;
import course.data.login.Login;
import course.ejb.login.LoginHome;

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

	private course.ejb.buy.BuyHome getHome() throws NamingException {
		return (course.ejb.buy.BuyHome) getContext().lookup(
				course.ejb.buy.BuyHome.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 String getCashCanUsed(String userName) {
		String cashCanUsed = null;

		try {
			course.ejb.buy.Buy buy = getHome().create();

			cashCanUsed = buy.getCashCanUsed(userName);

		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (CreateException e) {
			e.printStackTrace();
		} catch (NamingException e) {
			e.printStackTrace();
		}
		return cashCanUsed;
	}

	public ArrayList getStkInf(String stkID) {
		ArrayList list = null;

		try {
			course.ejb.buy.Buy buy = getHome().create();

			list = buy.getStkInf(stkID);

		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (CreateException e) {
			e.printStackTrace();
		} catch (NamingException e) {
			e.printStackTrace();
		}
		return list;
	}

	public void InsertStkOwnInf(Buy buyData) {

		try {
			course.ejb.buy.Buy buy = getHome().create();

			buy.InsertStkOwnInf(buyData);

		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (CreateException e) {
			e.printStackTrace();
		} catch (NamingException e) {
			e.printStackTrace();
		}
	}

	public void UpdateUserInf(UserInf userInf) {

		try {
			course.ejb.buy.Buy buy = getHome().create();

			buy.UpdateUserInf(userInf);

		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (CreateException e) {
			e.printStackTrace();
		} catch (NamingException e) {
			e.printStackTrace();
		}

	}

}

⌨️ 快捷键说明

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