/*
* Created on Feb 23, 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package struts.sample.cap10.sample3.ejb;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.FinderException;
import javax.ejb.NoSuchEntityException;
import javax.ejb.RemoveException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import struts.sample.cap10.sample3.entity.AttackSolution;
/**
* XDoclet-based BMP entity bean.
*
* To generate EJB related classes using XDoclet: - Add Standard EJB module to
* XDoclet project properties - Customize XDoclet configuration - Run XDoclet
*
* Below are the xdoclet-related tags needed for this EJB.
*
* @ejb.bean name="AttackSolutionEntity" display-name="Name for AttackSolutionEntity"
* description="Description for AttackSolutionEntity"
* jndi-name="ejb/AttackSolutionEntity" type="BMP" view-type="remote"
*/
public class AttackSolutionBMP implements EntityBean {
private String attack_event_code;
private String attack_mean;
private String attack_action;
/** The entity context */
private EntityContext context;
private DataSource ds;
private String dbjndi = "PostgresDS";
private Connection con;
/**
* @return Returns the attack_action.
*/
public String getAttack_action() {
return attack_action;
}
/**
* @param attack_action
* The attack_action to set.
*/
public void setAttack_action(String attack_action) {
this.attack_action = attack_action;
}
/**
* @return Returns the attack_event_code.
*/
public String getAttack_event_code() {
return attack_event_code;
}
/**
* @param attack_event_code
* The attack_event_code to set.
*/
public void setAttack_event_code(String attack_event_code) {
this.attack_event_code = attack_event_code;
}
/**
* @return Returns the attack_mean.
*/
public String getAttack_mean() {
return attack_mean;
}
/**
* @param attack_mean
* The attack_mean to set.
*/
public void setAttack_mean(String attack_mean) {
this.attack_mean = attack_mean;
}
/**
*
*/
public AttackSolutionBMP() {
super();
// TODO Auto-generated constructor stub
}
/**
* There are zero or more ejbCreate <METHOD>(...) methods, whose signatures
* match the signatures of the create <METHOD>(...) methods of the entity
* bean?s home interface. The container invokes an ejbCreate <METHOD>(...)
* method on an entity bean instance when a client invokes a matching create
* <METHOD>(...) method on the entity bean?s home interface. <br>
*
* The entity bean provider?s responsibility is to initialize the instance
* in the ejbCreate < METHOD>(...) methods from the input arguments, using
* the get and set accessor methods, such that when the ejbCreate
* <METHOD>(...) method returns, the persistent representation of the
* instance can be created. <br>
*
* The entity bean provider must not attempt to modify the values of
* cmr-fields in an ejbCreate < METHOD(...) method; this should be done in
* the ejbPostCreate <METHOD(...) method instead. <br>
*
* The entity object created by the ejbCreate <METHOD>method must have a
* unique primary key. This means that the primary key must be different
* from the primary keys of all the existing entity objects within the same
* home. However, it is legal to reuse the primary key of a previously
* removed entity object. The implementation of the bean provider?s
* ejbCreate < METHOD>(...) methods should be coded to return a null. <br>
*
* An ejbCreate <METHOD>(...) method executes in the transaction context
* determined by the transaction attribute of the matching create
* <METHOD>(...) method. The database insert operations are performed by the
* container within the same transaction context after the Bean Provider?s
* ejbCreate <METHOD>(...) method completes.
*
* @throws CreateException
* Thrown if method fails due to system-level error.
*
* @throws CreateException
*
* @ejb.create-method
*/
public String ejbCreate(String attack_event_code, String attack_mean,
String attack_action) throws CreateException {
PreparedStatement ps = null;
try {
//SQL语句“插入fw_attacksolution表”
String sql = " INSERT INTO fw_attacksolution(attack_event_code,"
+ "attack_mean, attack_action) VALUES (?,?,?)";
con = ds.getConnection();
//利用Connection对象的prepareStatement方法创建一个对象
//该对象将被作为PreparedStatement接口的一个接口实例
ps = con.prepareStatement(sql);
//将攻击类别代码号进行SQL预处理
ps.setString(1, attack_event_code);
//将攻击类别含义进行SQL预处理
ps.setString(2, attack_mean);
//将攻击类别的处理解决方法进行SQL预处理
ps.setString(3, attack_action);
//执行SQL并判断是否已经有一条记录被插入。
//executeUpdate方法判断是否有一条记录被更动,若更动则为1,否则则为0
if (ps.executeUpdate() != 1) {
//若没有更动一条记录则表示出错,将抛出错误。表示添加结果失败
throw new EJBException();
}
} catch (SQLException sqle) {
throw new EJBException(sqle);
} finally {
//在完成整段代码的工作后必须将JDBC连接关闭
try {
if (ps != null) {
ps.close();
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("ERROR.UNEXPECTED");
}
}
this.setAttack_event_code(attack_event_code);
this.setAttack_mean(attack_mean);
this.setAttack_action(attack_action);
return attack_event_code;
}
/**
* For each ejbCreate <METHOD>(...) method, there is a matching
* ejbPostCreate < METHOD>(...) method that has the same input parameters
* but whose return type is void. The container invokes the matching
* ejbPostCreate <METHOD>(...) method on an instance after it invokes the
* ejbCreate <METHOD>(...) method with the same arguments. The instance can
* discover the primary key by calling getPrimaryKey() on its entity context
* object. <br>
*
* The entity object identity is available during the ejbPostCreate
* <METHOD>(...) method. The instance may, for example, obtain the component
* interface of the associated entity object and pass it to another
* enterprise bean as a method argument. <br>
*
* The entity Bean Provider may use the ejbPostCreate <METHOD>(...) to set
* the values of cmr-fields to complete the initialization of the entity
* bean instance. An ejbPostCreate <METHOD>(...) method executes in the same
* transaction context as the previous ejbCreate <METHOD>(...) method.
*
* @throws CreateException
* Thrown if method fails due to system-level error.
*/
p
没有合适的资源?快使用搜索试试~ 我知道了~
Struts
共539个文件
java:137个
class:134个
tld:86个
需积分: 3 0 下载量 96 浏览量
2008-07-07
19:13:34
上传
评论
收藏 645KB RAR 举报
温馨提示
Struts 教程
资源详情
资源评论
资源推荐
收起资源包目录
Struts (539个子文件)
jdbc.properties.bak 240B
AttackSolutionBMP.class 8KB
AttackSolutionEntityBMP.class 8KB
AttackSolutionDAOImpl.class 7KB
MemoryUserDatabase.class 7KB
SaveRegistrationAction.class 6KB
SaveSubscriptionAction.class 6KB
EditSubscriptionAction.class 5KB
AttackSolutionDAO.class 5KB
AttackSolutionServices.class 5KB
MemoryDatabasePlugIn.class 5KB
AttackSolutionDAOI.class 4KB
AttackSolutionEntityUtil.class 4KB
MemoryUser.class 4KB
LogonAction.class 4KB
TestJbossEntityCMP.class 4KB
EditRegistrationAction.class 4KB
LinkSubscriptionTag.class 4KB
LinkUserTag.class 4KB
AttackSolutionServices.class 3KB
DeleteAttackSolutionAction.class 3KB
AddAttackSolutionAction.class 3KB
AddAttackSolutionAction.class 3KB
DeleteAttackSolutionAction.class 3KB
TestIbatis.class 3KB
TestJbossEntityBMP.class 3KB
AddAttackSolutionAction.class 3KB
DeleteAttackSolutionAction.class 3KB
SubscriptionForm.class 3KB
DeleteAttackSolutionAction.class 3KB
DeleteAttackSolutionAction.class 3KB
AttackSolutionDAOI.class 3KB
AddAttackSolutionAction.class 3KB
AddAttackSolutionAction.class 3KB
RegistrationForm.class 3KB
MailInfoServiceI.class 3KB
SearchAttackSolutionAction.class 3KB
SearchAttackSolutionAction.class 3KB
TestJbossNextWorld.class 2KB
TestJbossHelloWorld.class 2KB
SearchAttackSolutionAction.class 2KB
SearchAttackSolutionAction.class 2KB
SearchAttackSolutionAction.class 2KB
LogoffAction.class 2KB
CheckLogonTag.class 2KB
MemorySubscription.class 2KB
TestServlet.class 2KB
NewValidator.class 2KB
MemorySubscriptionCreationFactory.class 2KB
UserInfoDAOI.class 2KB
MailInfo.class 2KB
AttackSolutionCMP.class 2KB
UserInfoServiceI.class 2KB
AbstractFwAttacksolution.class 2KB
ShowAttackSolutionAction.class 2KB
SetCharacterEncodingFilter.class 2KB
SetCharacterEncodingFilter.class 2KB
SetCharacterEncodingFilter.class 2KB
SetCharacterEncodingFilter.class 2KB
SetCharacterEncodingFilter.class 2KB
TestWeblogicHelloWorld.class 2KB
ShowAttackSolutionAction.class 2KB
AttackSolutionServicesI.class 2KB
HibernateSessionFactory.class 2KB
AttackSolutionEntityCMP.class 2KB
AttackSolutionActionForm.class 2KB
AttackSolutionActionForm.class 2KB
AttackSolutionActionForm.class 2KB
AttackSolutionActionForm.class 2KB
AttackSolutionActionForm.class 2KB
MailInfoDAOI.class 2KB
UserInfo.class 2KB
I18SelectAction.class 2KB
ShowAttackSolutionAction.class 2KB
MemoryUserCreationFactory.class 2KB
AttackSolutionExample.class 2KB
AttackSolutionServicesI.class 2KB
ShowAttackSolutionAction.class 2KB
ShowAttackSolutionAction.class 2KB
NextWorld.class 1KB
NextWorldSession.class 1KB
AttackSolution.class 1KB
IbatisSQLMapConfig.class 1KB
PattackDocument.class 1KB
IbatisDAOConfig.class 1KB
AttackSolution.class 1KB
AttackSolutionDAOI$4.class 1KB
AttackSolutionDAOI$3.class 1KB
TestSpring.class 1KB
AttackSolutionDAOI$2.class 1KB
HelloWorldAction.class 1KB
HelloWorldSession.class 1KB
HelloWorld.class 1KB
CheckForm.class 1KB
AttackSolutionEntityData.class 1KB
HelloWorldActionForm.class 1KB
SaveAction.class 1KB
EncodeActionServlet.class 1KB
EncodeActionServlet.class 1KB
EncodeActionServlet.class 1KB
共 539 条
- 1
- 2
- 3
- 4
- 5
- 6
chensw1986
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0