JAVA代码银行销户 java编写程序模拟银行账户功能

javaweb写代码中注销如何实现点击注销,跳转到后台,去掉当前用户session,然后跳转登录界面 。
用java编的银行账户系统代码package pack.money.persistent;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;import pack.money.entity.Client;
import pack.money.entity.ClientMessage;
public class ClientPersistent {
//private static int a=0;
private static String t,b;//t是passwordb是clinetname
private static ClientPersistent sp;
public static ClientPersistent getClientPersistent() {
if (sp == null) {
sp = new ClientPersistent();
}
return sp;
}
private ClientMessage getClientMessage(ResultSet rs) throws Exception{
ClientMessage student=new ClientMessage();
student.setMoney(rs.getFloat("money"));
student.setType(rs.getString("type"));
student.setClientName(rs.getString("ClientName"));
student.setTransactionID(rs.getInt("TransactionID"));
return student;
}
public Client login(Connection con,String ClientName,String password) throws Exception{
String sql="select balance,password,ClientName from Client where ClientName=? and password=?";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1, ClientName);
ps.setString(2, password);
ResultSet rs=ps.executeQuery();
t=password;
b=ClientName;
System.out.println(t);
System.out.println(b);
if(rs.next()){
Client client=new Client();
client.setClientName(rs.getString("ClientName"));
client.setPassword(rs.getString("password"));
return client;}
throw new Exception("Can not login, the accountID or password has error. ");
} public void save(Connection con ,String money)throws Exception
{// a;
String s="save";
float g=Float.parseFloat(money);
String sql="update Client set balance=balance ? where ClientName=?";
String sql1="insert into ATMTransaction(ClientName,Type,money)values(?,?,?) ";
PreparedStatement ps=con.prepareStatement(sql);
PreparedStatement ps1=con.prepareStatement(sql1);
ps.setFloat(1, g);
ps.setString(2,b);
//ps1.setInt(1,a);
ps1.setString(1,b);
ps1.setString(2,s);
ps1.setFloat(3,g);
ps.executeUpdate();
ps1.executeUpdate();
}
public void withDraw (Connection con ,String money)throws Exception
{//a;
String s="WithDraw";
float x=Float.parseFloat(money);
String sql="update Client set balance=balance-? where ClientName=?";
String sql1="insert into ATMTransaction(ClientName,Type,money) values(?,?,?)";
PreparedStatement ps=con.prepareStatement(sql);
PreparedStatement ps1=con.prepareStatement(sql1);
ps.setFloat(1, x);
ps.setString(2,b);
//ps1.setInt(1,a);
ps1.setString(1,b);
ps1.setString(2,s);
ps1.setFloat(3,x);
ps.executeUpdate();
ps1.executeUpdate();
}
public String changePassword(Connection con, String OldPassWord,String newPassWord1,String newPassWord2)
throws Exception
{
if(t.equals(OldPassWord))
{
if(newPassWord1.equals(newPassWord2))
{
String sql="update Client set password=? where ClientName=?";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1, newPassWord1);
ps.setString(2,b);
ps.executeUpdate();
String j="dsfasdf";
return j;
}
else
{System.out.print("确认密码错误!");brreturn null;}
}
else
{return null;
}
}
public ArrayListClientMessage disPlayAll(Connection con ) throws Exception
{
String sql="select * from ATMTransaction where ClientName=? ";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1,b);
System.out.println(b "****b****");
ResultSet rs=ps.executeQuery();
ArrayListClientMessage message=new ArrayListClientMessage();
while(rs.next()){
message.add(this.getClientMessage(rs));
}
return message;
}
public float showBalance(Connection con ) throws Exception
{
String sql="select balance from Client where ClientName=?";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1, b);
ResultSet rs=ps.executeQuery();
if(rs.next())
{
float s;
s=rs.getFloat("balance");
return s;
}
else return 0 ;
}
}
怎么用java写银行管理系统的销户功能只要销户就可以了1.开户2.销户3.存钱4.取钱5.查询技术点:TcpServer服务端TcpSocket客户端多线程并发访问数据库存储数据XML组织传输JAVA代码银行销户的数据
【JAVA代码银行销户 java编写程序模拟银行账户功能】JAVA代码银行销户的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java编写程序模拟银行账户功能、JAVA代码银行销户的信息别忘了在本站进行查找喔 。

    推荐阅读