📄 collegestudentinfo.java
字号:
package internetsignup;
import java.sql.*;
import java.util.Date;
public class CollegeStudentInfo
{
private String userName="";
private String userPassword="";
private String speciality="";
private String signSelect="";
private String sname="";
private String sex="";
private String birthday="";
private String nation="";
private String identityNo="";
private String ifMember="";
private String ownAddress="";
private String graduateSchool="";
private String signType="";
private String address="";
private String mailNo="";
private String fatherName="";
private String fatherJob="";
private String fatherPhone="";
private String motherName="";
private String motherJob="";
private String motherPhone="";
private String cultureExtent="";
private String score="";
private String housePhone="";
private String mobile="";
private String remark="";
private String schoolOpinion="";
private String signupDate="";
Connection conn=null;
ResultSet rs=null;
Statement stmt=null;
public void setUserName(String userName)
{
this.userName=userName;
}
public void setUserPassword(String userPassword)
{
this.userPassword=userPassword;
}
public void setSpeciality(String speciality)
{
this.speciality=speciality;
}
public void setSignSelect(String signSelect)
{
this.signSelect=signSelect;
}
public void setSname(String sname)
{
this.sname=sname;
}
public void setSex(String sex)
{
this.sex=sex;
}
public void setBirthday(String birthday)
{
this.birthday=birthday;
}
public void setNation(String nation)
{
this.nation=nation;
}
public void setIdentityNo(String identityNo)
{
this.identityNo=identityNo;
}
public void setIfMember(String ifMember)
{
this.ifMember=ifMember;
}
public void setOwnAddress(String ownAddress)
{
this.ownAddress=ownAddress;
}
public void setGraduateSchool(String graduateSchool)
{
this.graduateSchool=graduateSchool;
}
public void setSignType(String signType)
{
this.signType=signType;
}
public void setAddress(String address)
{
this.address=address;
}
public void setMailNo(String mailNo)
{
this.mailNo=mailNo;
}
public void setFatherName(String fatherName)
{
this.fatherName=fatherName;
}
public void setFatherJob(String fatherJob)
{
this.fatherJob=fatherJob;
}
public void setFatherPhone(String fatherPhone)
{
this.fatherPhone=fatherPhone;
}
public void setMotherName(String motherName)
{
this.motherName=motherName;
}
public void setMotherJob(String motherJob)
{
this.motherJob=motherJob;
}
public void setMotherPhone(String motherPhone)
{
this.motherPhone=motherPhone;
}
public void setCultureExtent(String cultureExtent)
{
this.cultureExtent=cultureExtent;
}
public void setScore(String score)
{
this.score=score;
}
public void setHousePhone(String housePhone)
{
this.housePhone=housePhone;
}
public void setMobile(String mobile)
{
this.mobile=mobile;
}
public void setRemark(String remark)
{
this.remark=remark;
}
public void setSchoolOpinion(String schoolOpinion)
{
this.schoolOpinion=schoolOpinion;
}
public void setSignupDate(String signupDate)
{
this.signupDate=signupDate;
}
public String getUserName()
{
return userName;
}
public String getUserPassword()
{
return userPassword;
}
public String getSpeciality()
{
return speciality;
}
public String getSignSelect()
{
return signSelect;
}
public String getSname()
{
return sname;
}
public String getSex()
{
return sex;
}
public String getBirthday()
{
return birthday;
}
public String getNation()
{
return nation;
}
public String getIdentityNo()
{
return identityNo;
}
public String getIfMember()
{
return ifMember;
}
public String getOwnAddress()
{
return ownAddress;
}
public String getGraduateSchool()
{
return graduateSchool;
}
public String getSignType()
{
return signType;
}
public String getAddress()
{
return address;
}
public String getMailNo()
{
return mailNo;
}
public String getFatherName()
{
return fatherName;
}
public String getFatherJob()
{
return fatherJob;
}
public String getFatherPhone()
{
return fatherPhone;
}
public String getMotherName()
{
return motherName;
}
public String getMotherJob()
{
return motherJob;
}
public String getMotherPhone()
{
return motherPhone;
}
public String getCultureExtent()
{
return cultureExtent;
}
public String getScore()
{
return score;
}
public String getHousePhone()
{
return housePhone;
}
public String getMobile()
{
return mobile;
}
public String getRemark()
{
return remark;
}
public String getSchoolOpinion()
{
return schoolOpinion;
}
public String getSignupDate()
{
return signupDate;
}
public CollegeStudentInfo()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{
System.out.println(e);
}
}
public int saveMessage()
{
String s=checkUserName();
if(s.equals("success"))
{
try
{
conn=DriverManager.getConnection("jdbc:odbc:College","njgcxx","njgcxx");
stmt=conn.createStatement();
Date d=new Date();
signupDate=(1900+d.getYear())+"-"+(d.getMonth()+1)+"-"+d.getDate();
String sql="insert into CollegeStudentInfo values('"+userName+"','"+userPassword+
"','"+speciality+"','"+signSelect+"','"+sname+"','"+sex+"','"+birthday+"','"+nation
+"','"+identityNo+"','"+ifMember+"','"+ownAddress+"','"+graduateSchool+"','"+signType
+"','"+address+"','"+mailNo+"','"+fatherName+"','"+fatherJob+"','"+fatherPhone+"','"
+motherName+"','"+motherJob+"','"+motherPhone+"','"+cultureExtent+"','"+score
+"','"+housePhone+"','"+mobile+"','"+remark+"','"+schoolOpinion+"','"+signupDate+"')";
int i=stmt.executeUpdate(sql);
return i;
}
catch(Exception e)
{
System.out.println(e);
return 0;
}
finally
{
try{stmt.close();conn.close();}
catch(Exception e){}
}
}
else return -1;
}
public int selectMessage()
{
try
{
conn=DriverManager.getConnection("jdbc:odbc:College","njgcxx","njgcxx");
stmt=conn.createStatement();
String sql="select * from CollegeStudentInfo where userName='"+userName+"'";
rs=stmt.executeQuery(sql);
if(rs.next())
{
userPassword=rs.getString("userPassword").trim();
speciality=rs.getString("speciality").trim();
signSelect=rs.getString("signSelect").trim();
sname=rs.getString("sname").trim();
sex=rs.getString("sex").trim();
birthday=rs.getString("birthday").trim();
nation=rs.getString("nation").trim();
identityNo=rs.getString("identityNo").trim();
ifMember=rs.getString("ifMember").trim();
ownAddress=rs.getString("ownAddress").trim();
graduateSchool=rs.getString("graduateSchool").trim();
signType=rs.getString("signType").trim();
address=rs.getString("address").trim();
mailNo=rs.getString("mailNo").trim();
fatherName=rs.getString("fatherName").trim();
fatherJob=rs.getString("fatherJob").trim();
fatherPhone=rs.getString("fatherPhone").trim();
motherName=rs.getString("motherName").trim();
motherJob=rs.getString("motherJob").trim();
motherPhone=rs.getString("motherPhone").trim();
cultureExtent=rs.getString("cultureExtent").trim();
score=rs.getString("score").trim();
housePhone=rs.getString("housePhone").trim();
mobile=rs.getString("mobile").trim();
remark=rs.getString("remark").trim();
schoolOpinion=rs.getString("schoolOpinion").trim();
signupDate=rs.getString("signupDate").trim();
return 1;
}
else
{
return 0;
}
}
catch(Exception e)
{
System.out.println(e.toString());
return 0;
}
finally
{
try{stmt.close();conn.close();}
catch(Exception e){}
}
}
public int updateMessage()
{
try
{
conn=DriverManager.getConnection("jdbc:odbc:College","njgcxx","njgcxx");
stmt=conn.createStatement();
String sql="update CollegeStudentInfo set userPassword='"+userPassword+
"',speciality='"+speciality+"',signSelect='"+signSelect+"',sname='"+sname+"',sex='"+sex+"',birthday='"
+birthday+"',nation='"+nation+"',identityNo='"+identityNo+"',ifMember='"+ifMember+"',ownAddress='"+ownAddress+"',graduateSchool='"+graduateSchool+"',signType='"+signType
+"',address='"+address+"',mailNo='"+mailNo+"',fatherName='"+fatherName+"',fatherJob='"+fatherJob+"',fatherPhone='"+fatherPhone+"',motherName='"
+motherName+"',motherJob='"+motherJob+"',motherPhone='"+motherPhone+"',cultureExtent='"+cultureExtent+"',score='"+score
+"',housePhone='"+housePhone+"',mobile='"+mobile+"',remark='"+remark+"',schoolOpinion='"+schoolOpinion+"' where userName='"+userName+"'";
int i=stmt.executeUpdate(sql);
return i;
}
catch(Exception e)
{
System.out.println(e);
return 0;
}
finally
{
try{stmt.close();conn.close();}
catch(Exception e){}
}
}
public String checkLogin()
{
try
{
conn= DriverManager.getConnection("jdbc:odbc:College", "njgcxx", "njgcxx");
stmt=conn.createStatement();
rs=stmt.executeQuery("select * from CollegeStudentInfo where userName='"+userName+"' and userPassword='"+userPassword+"'");
if(rs.next()) return "success";
else return "fail";
}
catch(Exception e)
{
return "exception";
}
finally
{
try{stmt.close();conn.close();}
catch(Exception e){}
}
}
public String checkUserName()
{
try
{
conn= DriverManager.getConnection("jdbc:odbc:College", "njgcxx", "njgcxx");
stmt=conn.createStatement();
rs=stmt.executeQuery("select * from CollegeStudentInfo where userName='"+userName+"'");
if(rs.next()) return "fail";
else return "success";
}
catch(Exception e)
{
return "exception";
}
finally
{
try{stmt.close();conn.close();}
catch(Exception e){}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -