?? userinfo.java
字號(hào):
/*
* UserInfo.java
*
* Created on 2008年7月10日, 下午1:28
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package serverBag;
import java.sql.*;
import publicBag.*;
/**
*
* @author Administrator
*/
public class UserInfo implements UpdateDB{
private Connection con;
//JavaBean屬性
private String userID;
private String name;
private String pw;
private String question;
private String answer;
public String getUserID(){ return userID;}
public void setUserID(String inUserID){ userID = inUserID;}
public String getName(){return name;}
public void setName(String inName){name = inName;}
public String getPw(){return pw;}
public void setPw(String inPw){pw = inPw;}
public String getQuestion(){return question;}
public void setQuestion(String inQuestion){question = inQuestion;}
public String getAnswer(){return answer;}
public void setAnswer(String inAnswer){answer = inAnswer;}
/** Creates a new instance of UserInfo */
public UserInfo() {
try
{
con = ConnectDB.connectMusicDB();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public boolean validate()
{
try
{
boolean res = false;
PreparedStatement stat = con.prepareStatement("SELECT * FROM UserInfo WHERE cUserID=? AND cPassword=?");
stat.setString(1,userID);
stat.setString(2,pw);
ResultSet resultSet = stat.executeQuery();
res = resultSet.next();
if(res)
{
this.setName(resultSet.getString("cName"));
}
return res;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}
public boolean insertInfo() {
try
{
boolean res = false;
PreparedStatement stat = con.prepareStatement("INSERT UserInfo VALUES(?,?,?,?,?)");
stat.setString(1,userID);
stat.setString(2,pw);
stat.setString(3,name);
stat.setString(4,question);
stat.setString(5,answer);
int num = stat.executeUpdate();
if(num > 0)
{
res = true;
}
return res;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}
public boolean deleteInfo() {
return false;
}
public boolean updateInfo() {
return false;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -