Java-银行管理系统源代码.pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《Java-银行管理系统源代码.pdf》由会员分享,可在线阅读,更多相关《Java-银行管理系统源代码.pdf(34页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、JavaJava小型银行管理系统源代码(图形界面)小型银行管理系统源代码(图形界面)accounts.javaaccounts.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;/账户余额.之所以定义
2、为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
3、 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;pu
4、blic 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
5、;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
6、(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;priva
7、te ArrayListaccounts 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;/修改删除用
8、户数据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(
9、accounts user,int id)conn=getConnection();try Stringsql=updateaccountsetusername=?,userpwd=?,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
10、。getAccountType();pstmt。setDouble(5,user.getBalance();pstmt.setDouble(6,user。getCeiling());pstmt。executeUpdate();System。out。println(操作成功”);personId=?,return true;catch(SQLException e)e.printStackTrace();System.out.println(操作失败);return false;/插入用户数据public boolean accountDataInsert(accounts account)co
11、nn=getConnection();trypstmt=conn.prepareStatement(”insertintoaccount(username,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.setDoubl
12、e(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=co
13、nn。prepareStatement(sql);rs=pstmt.executeQuery();catch(SQLException e)userpwd,personId,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()
14、;catch(SQLException e)e。printStackTrace();System.out。println(检索失败);return rs;public ArrayListaccounts testt(int id)ArrayListaccounts list=new ArrayListaccounts();conn=getConnection();try String sql=”select*from account where id=+id;pstmt=conn.prepareStatement(sql);rs=pstmt。executeQuery();while(rs。ne
15、xt()accounts user=new accounts();user.setName(rs.getString(”username”);user。setPassword(rs。getString(userpwd”);user。setPersonId(rs.getString(personId);user.setAccountType(rs。getInt(”accountType));user。setBalance(rs.getDouble(”balance);user.setCeiling(rs.getDouble(”ceiling”));list。add(user);catch(SQL
16、Exception e)e。printStackTrace();System。out.println(”检索失败);return list;/根据卡号和密码验证用户是否存在public boolean verify(int id,String password)conn=getConnection();trypstmt=conn。prepareStatement(select*from account where id=?and userpwd=?);pstmt。setInt(1,id);pstmt。setString(2,password);rs=pstmt.executeQuery();i
17、f(rs.next())return true;elsereturn false;catch(SQLException e)e。printStackTrace();return false;/*登录验证/public accounts verifyAccount(int id,String password)boolean flag=verify(id,password);if(flag)accounts account=queryByIDandPassword(id,password);return account;elseSystem.out。println(用户不存在!);return
18、null;/根据卡号和密码查询信息public accounts queryByIDandPassword(int id,String password)conn=getConnection();trypstmt=conn.prepareStatement(”select*f rom account where id=?and userpwd=?);pstmt。setInt(1,id);pstmt。setString(2,password);rs=pstmt.executeQuery();accounts account=new accounts();while(rs。next()accoun
19、t。setId(rs.getInt(id);account.setName(rs.getString(”username);account.setPassword(rs。getString(”userpwd”));account。setPersonId(rs.getString(”personId);account。setAccountType(rs.getInt(accountType);account.setBalance(rs。getDouble(”balance”);account.setCeiling(rs。getDouble(”ceiling));return account;ca
20、tch(SQLException e)e。printStackTrace();return null;/根据卡号查询信息public accounts queryByID(int id)conn=getConnection();trypstmt=conn。prepareStatement(”select from account where id=?”);pstmt。setInt(1,id);rs=pstmt。executeQuery();accounts account=new accounts();while(rs.next()account.setId(rs.getInt(”id”));
21、account.setName(rs。getString(username));account。setPassword(rs。getString(”userpwd”));account.setPersonId(rs.getString(”personId”);account.setAccountType(rs.getInt(accountType”));account。setBalance(rs.getDouble(balance”);account。setCeiling(rs.getDouble(”ceiling));return account;catch(SQLException e)e
22、。printStackTrace();return null;public static void main(String args)/TODO Autogenerated method stubDBoper op=new DBoper();ArrayList list=op.testt(1001);for(int i=0;ilist.size();i+)accounts user=new accounts();user=list.get(i);System。out.println(user.getName());System.out.println(user。getPassword();Sy
23、stem。out.println(user。getPersonId();System.out.println(user。getAccountType());System。out。println(user。getBalance();System.out。println(user.getCeiling();/图像界面文件夹DN_SYSTEMDN_SYSTEMDefaultDefault。javajava/主界面主界面package DN_SYSTEM;import java.awt.Color;import java。awt。Container;import java。awt.event.Acti
24、onEvent;import java。awt.event。ActionListener;import javax.swing.JButton;import javax。swing。JFrame;import javax。swing。JLabel;import javax.swing。JOptionPane;import javax。swing.JPanel;import javax。swing。WindowConstants;import Account.accounts;import DB。DBoper;public class Default extends JFrame impleme
25、nts ActionListener accounts account=DN_ATM。client;DBoper db=new DBoper();private JFrame jf;private JButton btn0,btn1,btn2,btn3,btn4,btn5;private Container c;public void defaltDemo()/添加主界面卡片/DN_ATM。id;int id=DN_ATM.id;/account=db。queryByID(id);jf=new JFrame(DEFAULT”);c=jf。getContentPane();c。setLayout
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java 银行 管理 系统 源代码
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内