📄 bmpbeanbean.java
字号:
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 + -