📄 memberdb.java
字号:
package server;
import java.sql.*;
public class Memberdb extends database{
public Memberdb(String strDBName,String id,String pw){
super(strDBName,id,pw);
}
public boolean isExist() throws SQLException
{
if(rs.next())
return true;
else
return false;
}
public void QueryData(String strID,String strPW,String strQuestion,String strAnswer,int sort,int kind)
{
String strsqlQuery="";
if(kind==1)
{
strsqlQuery="select * from 用户 where id='"+strID+"' and password='"+strPW+"' and sort="+sort+"";
}
if(kind==2)
{
strsqlQuery="select * from 用户 where id='"+strID+"'and "+"sort="+sort+"";
}
if(kind==3)
{
strsqlQuery="select * from 用户 where id='"+strID+"'";
}
if(kind==4)
{
strsqlQuery="select * from 用户 where id='"+strID+"'"+" and password='"+strPW+"'";
}
if(kind==5)
{
strsqlQuery="select * from 用户 ";
}
try {
System.out.println(strsqlQuery);
rs=sql.executeQuery(strsqlQuery);
} catch (SQLException e) {
e.printStackTrace();
}
}
public void InsertNew(member Member)
{
String strsqlInsert="insert into 用户 (id,password,balance,question,answer,sort)values" +
"('"+Member.ID+"','"+Member.PassWord+"',0,'"+Member.Question+"','"
+Member.Answer+"','"+Member.sort+"')";
try {
sql.executeUpdate(strsqlInsert);
} catch (SQLException e) {
e.printStackTrace();
}
}
public member GetInfo() throws SQLException
{
member strMeg=new member();
if(rs.next())
{
strMeg.Question=rs.getString("question");
strMeg.Answer=rs.getString("answer");
strMeg.PassWord=rs.getString("password");
}
return strMeg;
}
public member GetInfo2() throws SQLException
{
member strMeg=new member();
strMeg.ID=rs.getString("id");
strMeg.sort=rs.getInt("sort");
strMeg.Balance=rs.getFloat("balance");
strMeg.Question=rs.getString("question");
strMeg.Answer=rs.getString("answer");
strMeg.PassWord=rs.getString("password");
return strMeg;
}
public float GetInfo3() throws SQLException
{
return rs.getFloat("balance");
}
public void updatedata(String columnName,Object x) throws SQLException
{
rs.absolute(1);
rs.updateObject(columnName,x);
rs.updateRow();
}
public void CloseAll(){
try {
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -