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

📄 bmpbeanbean.java~3~

📁 100多M的J2EE培训内容
💻 JAVA~3~
字号:
package com.cwj.userjmssesenbdb;

import javax.ejb.*;
import java.sql.*;
import javax.naming.*;

public class BMPBEANBean implements EntityBean {
  EntityContext entityContext;
  java.lang.String shancbz;
  java.lang.String xiwbz;
  Context ctx;
  public BMPBEANPK ejbCreate(java.lang.String shancbz, java.lang.String xiwbz) throws CreateException {
    /**@todo Complete this method*/
    PreparedStatement pstmt = null;
    Connection conn = null;
    setShancbz(shancbz);
    setXiwbz(xiwbz);
    try {
      System.out.println("ejbCreate() called.");
      this.shancbz = shancbz;
      this.xiwbz = xiwbz;
      conn = getConnection();
      pstmt = conn.prepareStatement(
          "insert into Aa11 (shancbz, xiwbz) values (?, ?)");
      pstmt.setString(1, shancbz);
      pstmt.setString(2, xiwbz);
      pstmt.executeUpdate();
      return new BMPBEANPK(shancbz);
    }catch (Exception e) {
      throw new CreateException(e.toString());
    }
    finally {
       try {
         if (pstmt != null) {
           pstmt.close();
         }
       }
       catch (Exception e) {}
        try {
              if (conn != null) {
                conn.close();
              }
        }
        catch (Exception e) {}
      }
  }

  public void ejbPostCreate(java.lang.String shancbz, java.lang.String xiwbz) throws CreateException {
    /**@todo Complete this method*/
  }
  public void ejbRemove() throws RemoveException {
    /**@todo Complete this method*/
  }
  public void ejbLoad() {
    /**@todo Complete this method*/
  }
  public void ejbStore() {
    /**@todo Complete this method*/
  }
  public void ejbActivate() {
    /**@todo Complete this method*/
  }
  public void ejbPassivate() {
    /**@todo Complete this method*/
  }
  public void unsetEntityContext() {
    this.entityContext = null;
  }  public void setEntityContext(EntityContext entityContext) {    this.entityContext = entityContext;  }
  public void setShancbz(java.lang.String shancbz) {    this.shancbz = shancbz;
  }
  public void setXiwbz(java.lang.String xiwbz) {    this.xiwbz = xiwbz;
  }
  public java.lang.String getShancbz() {    return shancbz;
  }
  public java.lang.String getXiwbz() {    return xiwbz;
  }
  public java.lang.String ejbFindByPrimaryKey(java.lang.String untitledField1) throws FinderException {
    /**@todo Complete this method*/
    return null;
  }
  public BMPBEANPK ejbFindByPrimaryKey(BMPBEANPK pk) throws FinderException {
    /**@todo Complete this method*/
    return null;
  }
  public java.sql.Connection getConnection() throws Exception {
    try {
      ctx = new InitialContext();
      javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup(
          "TestDataSource");
      return ds.getConnection();
    }
    catch (Exception ex) {
      System.err.println("Could not locate datasource! Reason:");
      ex.printStackTrace();
      throw ex;
    }
  }
  public BMPBEANPK ejbHomeEjbInsertAa11(String shancbz, String xiwbz) throws CreateException {
    PreparedStatement pstmt=null;
    Connection conn=null;
    try{
      System.out.println("ejbHomeEjbInsertAa11() called");
      this.shancbz=shancbz;
      this.xiwbz=xiwbz;
      conn=getConnection();
      pstmt=conn.prepareStatement("insert into Aa11(shancbz,xiwbz)values(?,?)");
      pstmt.setString(1,shancbz);
      pstmt.setString(2,xiwbz);
      pstmt.executeUpdate();
      return new BMPBEANPK(shancbz);
    }
    catch(Exception e){
      throw new CreateException(e.toString());
    }
    finally {
       try {
         if (pstmt != null) {
           pstmt.close();
         }
       }
       catch (Exception e) {}
        try {
              if (conn != null) {
                conn.close();
              }
        }
        catch (Exception e) {}
      }
  }
  public BMPBEANPK ejbHomeEjbdeleteAa11(String shancbz) {
    /**@todo Complete this method*/
    return null;
  }
}

⌨️ 快捷键说明

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