Java银行管理系统源代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
balance+=money;
}
//取款
publicvoid withdraw(double money){
if(accountType==1){
if((balance+ceiling)<money){
System.out.println("对不起,已超出您的信用额度!");
}
else{
balance-=money;
}catch(Exception e){
System.out.println("数据库连接失败");
}
returnconn;
}
//修改删除用户数据
publicboolean accountDataUpdate(String sql){
conn=getConnection();
try{
pstmt=conn.prepareStatement(sql);
Java
accounts.java
packageAccount;
publicclass accounts {
protected int id;//银行账号
protected String password;//用户密码
protected String name;//用户型号
protected String personId;//身份账号
//连接数据库
publicConnection getConnection(){
try{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bankmanager?useUnicode=true&characterEncoding=utf8","root","xuewei");
returnpassword;
}
publicvoid setPassword(String password){
this.password=password;
}
publicString getName(){
returnname;
}
publicvoid setName(String name){
this.name=name;
}
}else{
if(balance<money){
System.out.println("对不起,账户余额不足!");
}else{
balance-=money;
}
}
}
}
DBoper.java
packageDB;
importjava.sql.*;
importjava.util.ArrayList;
importAccount.accounts;
}
publicString getPersonId(){
returnpersonId;
}
publicvoid setPersonId(String personId){
this.personId=personId;
}
publicint getAccountType(){
returnaccountType;
publicclass DBoper {
privateConnection conn = null;
privateStatement st = null;
privatePreparedStatement pstmt = null;
privateResultSet rs = null;
privateArrayList<accounts> result;
this.ceiling=ceiling;
}
//无参数构造方法
publicaccounts(){
}
//构造方法
publicaccounts(String password,String name,String personId,int accountType,
doublebalance,double ceiling){
this.balance=balance;
}
publicint getId(){
returnid;
}
publicvoid setId(int id){
this.id=id;
}
publicdouble getCeiling(){
returnceiling;
}Leabharlann Baidu
publicvoid setCeiling(double ceiling){
pstmt.executeUpdate();
//System.out.println("数据更新成功");
conn.close();
returntrue;
}catch(SQLException e){
e.printStackTrace();
//System.out.println("更新失败");
returnfalse;
super();
this.password=password;
this.name=name;
this.personId=personId;
this.accountType=accountType;
this.balance=balance;
this.ceiling=ceiling;
}
//存款
publicvoid deposit(double money){
}
publicvoid setAccountType(int accountType){
this.accountType=accountType;
}
publicdouble getBalance(){
returnbalance;
}
publicvoid setBalance(double balance){
}
}
//依据id来修改记录
publicboolean dataupdateid(accounts user, int id) {
conn= getConnection();
try{
String sql = "update account set username=?,userpwd=?,personId=?,accountType=?,balance=?,ceiling=?whereid="
protected int accountType;//账号类型,0代表储蓄卡,1代表信用卡
protected double balance;//账户余额。之所以定义为protected是让他的子类可以直接用,不需要通过方法来赋值。
protecteddouble ceiling;
publicString getPassword(){
相关文档
最新文档