?? registerejb.java
字號:
import java.sql.*;
import javax.ejb.*;
import javax.sql.*;
import java.rmi.*;
import javax.rmi.*;
import javax.naming.*;
public class registerEJB implements EntityBean
{
String name,sex,password,repassword,pass_question,question_key,country,
province,city,Email,qq,company_name,phone,mobile_phone,postcode,address;
EntityContext context;
Connection con;
public void markconnection()
{
try
{
InitialContext ic=new InitialContext();
DataSource ds=(DataSource)ic.lookup("Bank");
con=ds.getConnection("sa","");
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
}
public String ejbCreate(String name) throws CreateException
{
try
{
if(name.equals(""))
{
throw new CreateException("not empty");
}
}
catch(Exception eq)
{
System.out.println("error ejb");
}
this.name=name;
this.sex=sex;
this.password=password;
this.repassword=repassword;
this.pass_question=pass_question;
this.question_key=question_key;
this.country=country;
this.province=province;
this.city=city;
this.Email=Email;
this.qq=qq;
this.company_name=company_name;
this.phone=phone;
this.mobile_phone=mobile_phone;
this.postcode=postcode;
this.address=address;
return name;
}
public int userfind(String name)
{
try
{
markconnection();
PreparedStatement st=con.prepareStatement("select name from register where name=?");
st.setString(1,name);
ResultSet rt=st.executeQuery();
if(rt.next())
{
return 0;
}
else
{
return 1;
}
}catch(Exception ex)
{
System.out.println(ex.getMessage());
return 1;
}
}
public int userinsert(String name,String sex,String password,String repassword,String pass_question,String
question_key,String country,String province,String city,String Email,String qq,String company_name,String phone,
String mobile_phone,String postcode,String address)
{
try
{
markconnection();
PreparedStatement pst=con.prepareStatement("insert register values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pst.setString(1,name);
pst.setString(2,sex);
pst.setString(3,password);
pst.setString(4,repassword);
pst.setString(5,pass_question);
pst.setString(6,question_key);
pst.setString(7,country);
pst.setString(8,province);
pst.setString(9,city);
pst.setString(10,Email);
pst.setString(11,qq);
pst.setString(12,company_name);
pst.setString(13,phone);
pst.setString(14,mobile_phone);
pst.setString(15,postcode);
pst.setString(16,address);
int i=pst.executeUpdate();
if(i>=0)
{
con.close();
return 0;
}
else
{
con.close();
return 1;
}
}
catch(Exception et)
{
System.out.println(et.getMessage());
return 1;
}
}
public void ejbPostCreate(String name){}
public void ejbLoad(){}
public void ejbStore(){}
public void ejbRemove(){}
public void ejbPassivate(){}
public void ejbActivate(){}
public void setEntityContext(EntityContext ec)
{
this.context=ec;
}
public void unsetEntityContext(){}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -