资源预览内容
第1页 / 共35页
第2页 / 共35页
第3页 / 共35页
第4页 / 共35页
第5页 / 共35页
第6页 / 共35页
第7页 / 共35页
第8页 / 共35页
第9页 / 共35页
第10页 / 共35页
亲,该文档总共35页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
Java小型银行管理系统源代码(图形界面)accounts.javapackage Account;public class accounts protected int id;/银行账号protected String password;/用户密码protected String name;/用户型号protected String personId;/身份账号protected int accountType;/账号类型,0代表储蓄卡,1代表信用卡protected double balance;/账户余额。之所以定义为protected是让他的子类可以直接用,不需要通过方法来赋值。protected double ceiling;public String getPassword()return password;public void setPassword(String password)this.password=password;public String getName()return name;public void setName(String name)this.name=name;public String getPersonId()return personId;public void setPersonId(String personId)this.personId=personId;public int getAccountType()return accountType;public void setAccountType(int accountType)this.accountType=accountType;public double getBalance()return balance;public void setBalance(double balance)this.balance=balance;public int getId()return id;public void setId(int id)this.id=id;public double getCeiling()return ceiling;public void setCeiling(double ceiling)this.ceiling=ceiling;/无参数构造方法public accounts()/构造方法public accounts(String password,String name,String personId,int accountType,double balance,double ceiling)super();this.password=password;this.name=name;this.personId=personId;this.accountType=accountType;this.balance=balance;this.ceiling=ceiling;/存款public void deposit(double money)balance+=money;/取款public void withdraw(double money)if(accountType=1)if(balance+ceiling)money)System.out.println(对不起,已超出您的信用额度!);elsebalance-=money;elseif(balancemoney)System.out.println(对不起,账户余额不足!);elsebalance-=money;DBoper.javapackage DB;import java.sql.*;import java.util.ArrayList;import Account.accounts;public class DBoper private Connection conn = null;private Statement st = null;private PreparedStatement pstmt = null;private ResultSet rs = null;private ArrayList result;/连接数据库public Connection getConnection()tryClass.forName(com.mysql.jdbc.Driver);conn=DriverManager.getConnection(jdbc:mysql:/localhost:3306/bankmanager?useUnicode=true&characterEncoding=utf8,root,xuewei);catch(Exception e)System.out.println(数据库连接失败);return conn;/修改 删除用户数据public boolean accountDataUpdate(String sql)conn=getConnection();trypstmt=conn.prepareStatement(sql);pstmt.executeUpdate();/System.out.println(数据更新成功);conn.close();return true;catch(SQLException e)e.printStackTrace();/System.out.println(更新失败);return false;/依据id来修改记录public boolean dataupdateid(accounts user, int id) conn = getConnection();try String sql = update account set username=?,userpwd=?,personId=?,accountType=?,balance=?,ceiling=? where id=+ id;pstmt = conn.prepareStatement(sql);pstmt.setString(1, user.getName();pstmt.setString(2, user.getPassword();pstmt.setString(3, user.getPersonId();pstmt.setInt(4, user.getAccountType();pstmt.setDouble(5, user.getBalance();pstmt.setDouble(6, user.getCeiling();pstmt.executeUpdate();System.out.println(操作成功);return true;catch (SQLException e) e.printStackTrace();System.out.println(操作失败);return false;/插入用户数据public boolean accountDataInsert(accounts account)conn=getConnection();trypstmt=conn.prepareStatement(insert into account (username,userpwd,personId,accountType,balance,ceiling) values (?,?,?,?,?,?);pstmt.setString(1, account.getName();pstmt.setString(2, account.getPassword();pstmt.setString(3, account.getPersonId();pstmt.setInt(4, account.getAccountType();pstmt.setDouble(5, account.getBalance();pstmt.setDouble(6, account.getCeiling();pstmt.executeUpdate();System.out.println(新用户数据插入成功);conn.close();return true;catch(SQLException e)e.printStackTrace();System.out.println(插入失败);return false;/查询数据public ResultSet dataquery(String sql) conn = getConnection();try pstmt = conn.prepareStatement(sql);rs = pstmt.executeQuery();catch (SQLException e) e.printStackTrace();System.out.println(检索失败);return rs;public ResultSet testlist() try String sql = select * from account where id =1001;pstmt = conn.prepareStatement(sql);System.out.println(sql);rs = pstmt.executeQuery(); catch (SQLException e) e.printStackTrace();System.out.println(检索失败);return rs;pu
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号