mysql中银行账号信息表_银行——————————账户信息存入数据库

packagecom.Bank.abc;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjava.util.ArrayList;importjava.util.HashMap;importjava.util.List;importjava.util.Map;importjava.util.Scanner;importcom.Bank.unionpay.ICard;//储蓄卡

public class CXCard implementsICard

{//属性

private double balance ; //账户余额

public doublegetBalance() {returnbalance;

}public void setBalance(doublebalance) {this.balance =balance;

}

AutoATM am= newAutoATM() ;

@Overridepublic voidchaXun()

{

System.out.println("************************************");

System.out.println("您选择的为查询功能!");//提供用户输入渠道

while(true)

{

System.out.println("请输入您的卡号:");

Scanner id= newScanner(System.in) ;

String idNum=id.nextLine();//判断用户输入卡号是否存在

try{

Class.forName("oracle.jdbc.driver.OracleDriver") ;

String url= "jdbc:oracle:thin:@localhost:1521:orcl" ; //本机地址

Connection conn= DriverManager.getConnection(url ,"test0816","934617699" );//建立连接

Statement st=conn.createStatement() ;//查询用户输入卡号的结果集

ResultSet rt = st.executeQuery("select * from account_Bank where kahao = ' " +idNum +" ' ") ;//if else 判断该结果集是否有数据

if(rt.next())

{

String ss= rt.getString("password") ;for(int i = 0 ; i<3; i++)

{

System.out.println("请输入您的密码:");

Scanner mm= newScanner(System.in) ;

String mima=mm.nextLine();if(ss.equals(mima))

{

System.out.println("姓名:"+rt.getString("name")+" "

+"\r卡号:"+rt.getString("kahao")+" "

+"\r身份证号:"+rt.getString("sfNum")+" "

+"\r账户余额:"+rt.getString("balance"));break;

}else{

System.out.println("重新输入密码!");

}

}break ; //跳出循环

}else{

System.out.println("卡号不存在!");

}

st.close();

rt.close();

conn.close();

}catch (ClassNotFoundException |SQLException e) {//TODO 自动生成的 catch 块

e.printStackTrace();

}//驱动加载

}

}

@Overridepublic voidcunKuan()

{

System.out.println("************************************");

System.out.println("您选择的为存款功能!");//提供用户输入渠道

while(true)

{

System.out.println("请输入您的卡号:");

Scanner id= newScanner(System.in) ;

String idNum=id.nextLine();//判断用户输入卡号是否存在

try{

Class.forName("oracle.jdbc.driver.OracleDriver") ;

String url= "jdbc:oracle:thin:@localhost:1521:orcl" ; //本机地址

Connection conn= DriverManager.getConnection(url ,"test0816","934617699" );//建立连接

Statement st=conn.createStatement() ;//查询用户输入卡号的结果集

ResultSet rt = st.executeQuery("select * from account_Bank where kahao = ' " +idNum +" ' ") ;//if else 判断该结果集是否有数据

if(rt.next())

{

String ss= rt.getString("password") ;for(int i = 0 ; i<3; i++)

{

System.out.println("请输入您的密码:");

Scanner mm= newScanner(System.in) ;

String mima=mm.nextLine();if(ss.equals(mima))

{

System.out.println("姓名:"+rt.getString("name")+" "

+"\r卡号:"+rt.getString("kahao")+" "

+"\r身份证号:"+rt.getString("sfNum")+" "

+"\r账户余额:"+rt.getString("balance"));

System.out.println("请输入您要存款的金额");

Scanner sr= new Scanner(System.in) ;//存款金额

double money =sr.nextDouble();if(money>0)

{double yue = rt.getDouble("balance") ;double sum =yue +money ;//将用户新的余额修改在数据库中

st.executeUpdate("update account_bank set balance= ' "

+sum+" ' where kahao = ' " +idNum +" ' ") ;

System.out.println("存款成功!\r 返回主界面请按1");

Scanner sss= newScanner(System.in) ;int t =sss.nextInt() ;if(t==1)

{

System.out.println("银行自助终端系统");

System.out.println("************************************");

System.out.println();

System.out.println("0——————开户");

System.out.println("1——————查询");

System.out.println("2——————存款");

System.out.println("3——————取款");

System.out.println("4——————退出");

System.out.println();

System.out.println("************************************");

System.out.println();

System.out.println("请选择您要执行的功能:");

}break;

}else{

System.out.println("您的存款金额不对!");

System.out.println("请重新输入密码,进行相关操作,您还有"+(3-i)+"次机会");

}

}else{

System.out.println("重新输入密码!");

}

}break ; //跳出循环

}else{

System.out.println("卡号不存在!");

}

st.close();

rt.close();

conn.close();

}catch (ClassNotFoundException |SQLException e) {//TODO 自动生成的 catch 块

e.printStackTrace();

}//驱动加载

}

}

@Overridepublic voidquKuan()

{

System.out.println("************************************");

System.out.println("您选择的为取款功能!");//提供用户输入渠道

while(true)

{

System.out.println("请输入您的卡号:");

Scanner id= newScanner(System.in) ;

String idNum=id.nextLine();//判断用户输入卡号是否存在

try{

Class.forName("oracle.jdbc.driver.OracleDriver") ;

String url= "jdbc:oracle:thin:@localhost:1521:orcl" ; //本机地址

Connection conn= DriverManager.getConnection(url ,"test0816","934617699" );//建立连接

Statement st=conn.createStatement() ;//查询用户输入卡号的结果集

ResultSet rt = st.executeQuery("select * from account_Bank where kahao = ' " +idNum +" ' ") ;//if else 判断该结果集是否有数据

if(rt.next())

{

String ss= rt.getString("password") ;for(int i = 0 ; i<3; i++)

{

System.out.println("请输入您的密码:");

Scanner mm= newScanner(System.in) ;

String mima=mm.nextLine();if(ss.equals(mima))

{

System.out.println("姓名:"+rt.getString("name")+" "

+"\r卡号:"+rt.getString("kahao")+" "

+"\r身份证号:"+rt.getString("sfNum")+" "

+"\r账户余额:"+rt.getString("balance"));

System.out.println("请输入您要取款的金额");

Scanner sr= new Scanner(System.in) ;//存款金额

double money =sr.nextDouble();if(money>0)

{double yue = rt.getDouble("balance") ;if(money <=yue)

{double sum =yue -money ;//将用户新的余额修改在数据库中

st.executeUpdate("update account_bank set balance= ' "

+sum+" ' where kahao = ' " +idNum +" ' ") ;

System.out.println("取款成功!\r 返回主界面请按1");

Scanner sss= newScanner(System.in) ;int t =sss.nextInt() ;if(t==1)

{

System.out.println("银行自助终端系统");

System.out.println("************************************");

System.out.println();

System.out.println("0——————开户");

System.out.println("1——————查询");

System.out.println("2——————存款");

System.out.println("3——————取款");

System.out.println("4——————退出");

System.out.println();

System.out.println("************************************");

System.out.println();

System.out.println("请选择您要执行的功能:");

}break;

}else{

System.out.println("您的账户余额不足!");

System.out.println("请重新输入密码,进行相关操作,您还有"+(3-i)+"次机会");

}

}else{

System.out.println("您的取款金额不对!");

System.out.println("请重新输入密码,进行相关操作,您还有"+(3-i)+"次机会");

}

}else{

System.out.println("重新输入密码!");

}

}break ; //跳出循环

}else{

System.out.println("卡号不存在!");

}

st.close();

rt.close();

conn.close();

}catch (ClassNotFoundException |SQLException e) {//TODO 自动生成的 catch 块

e.printStackTrace();

}//驱动加载

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值