Advertisement
masokis

JAVA- ATM system

Mar 23rd, 2011
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 54.76 KB | None | 0 0
  1. ////CardTransactions
  2.  
  3. import java.awt.*;            //
  4. import java.awt.event.*;     //   PACKAGES
  5. import javax.swing.*;       //
  6. import java.sql.*;         //
  7.  
  8. public class CardTransactions extends JFrame {
  9.        private JButton button1,button2,button3;
  10.        private JLabel label1,label2;
  11.        static String url = "jdbc:odbc:abc";
  12.        Container container;
  13.        //---Constructor---
  14.        public CardTransactions(){
  15.                  super(" Card Transactions");
  16.                  Container container = getContentPane();
  17.                  container.setLayout(null);
  18.  
  19.                  button1 = new JButton(">>>");
  20.                  button1.setPreferredSize(new Dimension(100,30));
  21.                  button1.setSize(button1.getPreferredSize());
  22.                  button1.setLocation(30,50);
  23.                  //---making connection with the database---
  24.                  button1.addActionListener(new ActionListener(){
  25.                         public void actionPerformed(ActionEvent event){
  26.                                try{
  27.                                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  28.                                 }catch(ClassNotFoundException a){
  29.                                  JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
  30.                                     }
  31.                         //--goes to DB2-ChangePword to execute changing password--
  32.                         DB2 s=new DB2();s.ChangePword();
  33.                         }
  34.                  });
  35.                  container.add(button1);
  36.  
  37.                  button2 = new JButton(">>>");
  38.                  button2.setPreferredSize(new Dimension(100,30));
  39.                  button2.setSize(button2.getPreferredSize());
  40.                  button2.setLocation(30,100);
  41.                  //--makes the connection with the database
  42.                  //--and goes to DB2 to execute paying dept
  43.                  button2.addActionListener(new ActionListener(){
  44.                       public void actionPerformed(ActionEvent event){
  45.                             DB2 s=new DB2();s.DeptPaying();
  46.                       }
  47.                  });
  48.                  container.add(button2);
  49.  
  50.                  button3 = new JButton("<BACK>");
  51.                  button3.setPreferredSize(new Dimension(100,30));
  52.                  button3.setSize(button3.getPreferredSize());
  53.                  button3.setLocation(30,150);
  54.                  button3.addActionListener(new ActionListener(){
  55.                         public void actionPerformed(ActionEvent event){
  56.                 DB2 s=new DB2();s.Back();
  57.                         }
  58.                  });
  59.                  container.add(button3);
  60.  
  61.                  label1 = new JLabel("Change Password");
  62.                  label1.setPreferredSize(new Dimension(120,30));
  63.                  label1.setSize(label1.getPreferredSize());
  64.                  label1.setLocation(130,45);
  65.                  container.add(label1);
  66.  
  67.                  label2 = new JLabel("Dept paying");
  68.                  label2.setPreferredSize(new Dimension(120,30));
  69.                  label2.setSize(label2.getPreferredSize());
  70.                  label2.setLocation(130,98);
  71.                  container.add(label2);
  72.  
  73.                  setSize(400,350);
  74.                  setVisible(true);
  75.        }//--end of constructor
  76.  
  77. }
  78.  
  79.  
  80.  
  81.  
  82. ////CASH
  83.  
  84.  
  85. import java.awt.*;             //
  86. import java.awt.event.*;      //    PACKAGES
  87. import javax.swing.*;        //
  88. import java.sql.*;          //
  89.        public class Cash extends JFrame implements ActionListener{
  90.           public JButton button1,button2,button3,button4,button5,button6,cancelBut;
  91.           private JLabel label1,label2,label3,label4,label5,label6;
  92.           private JTextField textField;
  93.           static String url = "jdbc:odbc:abc";
  94.           //---Constructor---
  95.           public Cash(){
  96.                  super("Cash");
  97.                  Container container=getContentPane() ;
  98.                  container.setLayout(null);
  99.  
  100.                  textField=new JTextField(10);
  101.                  button1 = new JButton(">>>");
  102.                  button1.setPreferredSize(new Dimension(100,30));
  103.                  button1.setSize(button1.getPreferredSize());
  104.                  button1.setLocation(50,50);
  105.                  button1.addActionListener(this);
  106.                  container.add(button1);
  107.  
  108.                  button2 = new JButton(">>>");
  109.                  button2.setPreferredSize(new Dimension(100,30));
  110.                  button2.setSize(button2.getPreferredSize());
  111.                  button2.setLocation(50,100);
  112.                  button2.addActionListener(this);
  113.                  container.add(button2);
  114.  
  115.                  button3 = new JButton(">>>");
  116.                  button3.setPreferredSize(new Dimension(100,30));
  117.                  button3.setSize(button3.getPreferredSize());
  118.                  button3.setLocation(50,150);
  119.                  button3.addActionListener(this);
  120.                  container.add(button3);
  121.  
  122.                  button4 = new JButton("<<<");
  123.                  button4.setPreferredSize(new Dimension(100,30));
  124.                  button4.setSize(button4.getPreferredSize());
  125.                  button4.setLocation(375,50);
  126.                  //---makes the communication with the odbc Driver---
  127.                  button4.addActionListener(new ActionListener(){
  128.                         public void actionPerformed(ActionEvent event){
  129.                                if(event.getSource()==button1){
  130.                                try{
  131.                                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  132.                                 }catch(ClassNotFoundException a){
  133.                                  JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
  134.                                }}DB s=new DB();s.CashScreen();}
  135.                  });
  136.                  container.add(button4);
  137.  
  138.                  button5 = new JButton("<<<");
  139.                  button5.setPreferredSize(new Dimension(100,30));
  140.                  button5.setSize(button5.getPreferredSize());
  141.                  button5.setLocation(375,100);
  142.                  button5.addActionListener(this);
  143.                  container.add(button5);
  144.  
  145.                  button6 = new JButton("<<<");
  146.                  button6.setPreferredSize(new Dimension(100,30));
  147.                  button6.setSize(button6.getPreferredSize());
  148.                  button6.setLocation(375,150);
  149.                  //---makes the communication with the odbc Driver---
  150.                  button6.addActionListener(new ActionListener(){
  151.                         public void actionPerformed(ActionEvent event){
  152.                                if(event.getSource()==button1){
  153.                                try{
  154.                                  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  155.                                 }catch(ClassNotFoundException a){
  156.                                  JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
  157.                                }}DB s=new DB();s.ExecutionForAnother();}
  158.                  });
  159.  
  160.                  container.add(button6);
  161.  
  162.                  cancelBut = new JButton("CANCEL");
  163.                  cancelBut.setPreferredSize(new Dimension(100,30));
  164.                  cancelBut.setSize(cancelBut.getPreferredSize());
  165.                  cancelBut.setLocation(375,200);
  166.                  cancelBut.addActionListener(this);
  167.                  container.add(cancelBut);
  168.  
  169.                  label1=new JLabel("  10 $");
  170.                  label1.setPreferredSize(new Dimension(75,30));
  171.                  label1.setSize(label1.getPreferredSize());
  172.                  label1.setLocation(150,50);
  173.                  container.add(label1);
  174.  
  175.                  label2=new JLabel("      20 $");
  176.                  label2.setPreferredSize(new Dimension(75,30));
  177.                  label2.setSize(label2.getPreferredSize());
  178.                  label2.setLocation(300,50);
  179.                  container.add(label2);
  180.  
  181.                  label3=new JLabel("  40 $");
  182.                  label3.setPreferredSize(new Dimension(75,30));
  183.                  label3.setSize(label3.getPreferredSize());
  184.                  label3.setLocation(150,100);
  185.                  container.add(label3);
  186.  
  187.                  label4=new JLabel("      50 $");
  188.                  label4.setPreferredSize(new Dimension(75,30));
  189.                  label4.setSize(label4.getPreferredSize());
  190.                  label4.setLocation(300,100);
  191.                  container.add(label4);
  192.  
  193.                  label5=new JLabel("  100 $");
  194.                  label5.setPreferredSize(new Dimension(75,30));
  195.                  label5.setSize(label5.getPreferredSize());
  196.                  label5.setLocation(150,150);
  197.                  container.add(label5);
  198.  
  199.                  label6=new JLabel("  Another..");
  200.                  label6.setPreferredSize(new Dimension(85,30));
  201.                  label6.setSize(label6.getPreferredSize());
  202.                  label6.setLocation(300,150);
  203.                  container.add(label6);
  204.  
  205.                  setSize(500,400);
  206.                  setVisible(true);
  207.  
  208.           }//---Method for Actionlistener---
  209.           public void actionPerformed(ActionEvent event){
  210.              if(event.getSource()==cancelBut){
  211.                         this.hide();//closes the present application
  212.                         MainMenu s=new MainMenu();s.Main();//and goes to MainMenu
  213.              }
  214.  
  215.           }
  216. }
  217.  
  218.  
  219.  
  220. ////Main Menu
  221.  
  222.  
  223. import java.awt.event.* ;     //
  224. import javax.swing.* ;       //  PACKAGES
  225. import java.awt.* ;         //
  226. import java.sql.*;         //
  227.         //-----------------THE MAIN MENU---------------------
  228.     public class MainMenu extends JFrame implements ActionListener {
  229.             private JButton but1, but2, but3, but4, but5, but6,but7,but8,but9 ;
  230.                 private JLabel labb,label,label2,label3,label4,label4a,label5,label6,label6a,label7;
  231.                 private JTextArea textarea;
  232.                 private JPasswordField pwordfield;
  233.                 private int pw,intt;
  234.             static String url = "jdbc:odbc:abc";
  235.                 private String str1;
  236.             Container c;
  237.                 //--Constructor----
  238.             public MainMenu() {
  239.                     super("ATM");
  240.                 }
  241.                 //----Method Main(The main Method)-----
  242.             public void Main(){
  243.                       c = getContentPane() ;
  244.                       c.setLayout(null) ;
  245.  
  246.  
  247.                 but1 = new JButton(">>>") ;
  248.                 but1.setPreferredSize( new Dimension(100,30) ) ;
  249.                 but1.setSize( but1.getPreferredSize() ) ;
  250.                 but1.setLocation(50,50) ;
  251.                 but1.addActionListener(this) ;
  252.                 c.add(but1) ;
  253.  
  254.                       but2 = new JButton(">>>") ;
  255.                       but2.setPreferredSize( new Dimension(120,50) ) ;
  256.                       but2.setSize( but2.getPreferredSize() ) ;
  257.                       but2.setLocation(50,100) ;
  258.                       but2.addActionListener(this) ;
  259.                       c.add(but2) ;
  260.  
  261.                     but3=new JButton(">>>");
  262.                     but3.setPreferredSize(new Dimension(120,50));
  263.                     but3.setSize(but3.getPreferredSize());
  264.                     but3.addActionListener(this);
  265.                     but3.setLocation(50,150);
  266.                     c.add(but3);
  267.  
  268.                       but4 = new JButton("<<<");
  269.                       but4.setPreferredSize(new Dimension(120,50));
  270.                       but4.setSize(but4.getPreferredSize());
  271.                       but4.addActionListener(this);
  272.                       but4.setLocation(375,50);
  273.                       c.add(but4);
  274.  
  275.                     but5 = new JButton("<<<");
  276.                     but5.setPreferredSize(new Dimension(120,50));
  277.                     but5.setSize(but5.getPreferredSize());
  278.                     but5.setLocation(375,100);
  279.                     but5.addActionListener(this);
  280.                     c.add(but5);
  281.  
  282.                       but6 = new JButton("<<<");
  283.                       but6.setPreferredSize(new Dimension(120,50));
  284.                       but6.setSize(but6.getPreferredSize());
  285.                       but6.setLocation(375,150);
  286.                       but6.addActionListener(this);
  287.                       but6.addActionListener(new ActionListener(){
  288.                         //----Creating the odbc Driver for but6-----
  289.                         public void actionPerformed(ActionEvent event){
  290.                           if(event.getSource()==but6){
  291.                             try{
  292.                                     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  293.                                     }catch(ClassNotFoundException a){
  294.                                         JOptionPane.showMessageDialog(
  295.             null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
  296.                                     }
  297.                           }
  298.                         }
  299.  
  300.  
  301.                       });
  302.                       c.add(but6);
  303.  
  304.                     but7 = new JButton("CANCEL");
  305.                     but7.setPreferredSize(new Dimension(120,50));
  306.                     but7.setSize(but7.getPreferredSize());
  307.                     but7.setLocation(200,212);
  308.                     but7.addActionListener(this);
  309.                     c.add(but7);
  310.  
  311.                       label=new JLabel("CASH");
  312.                       label.setPreferredSize(new Dimension(75,50));
  313.                       label.setSize(label.getPreferredSize());
  314.                       label.setLocation(160,40);
  315.                       label.setToolTipText("to draw money,please click on the left button");
  316.                       c.add(label);
  317.  
  318.                     label2 = new JLabel(" INFORMATION");
  319.                     label2.setPreferredSize(new Dimension(85,50));
  320.                         label2.setSize(label2.getPreferredSize());
  321.                     label2.setLocation(280,40);
  322.                     label2.setToolTipText("For information,please click on the left button");
  323.                     c.add(label2);
  324.  
  325.                       label3 = new JLabel("TRANSFER");
  326.                       label3.setPreferredSize(new Dimension(85,50));
  327.                       label3.setSize(label3.getPreferredSize());
  328.                       label3.setLocation(160,90);
  329.                       label3.setToolTipText("for referring money,click on the right button");
  330.                       c.add(label3);
  331.  
  332.                     label4 = new JLabel("CARD ");
  333.                     label4.setPreferredSize(new Dimension(85,50));
  334.                     label4.setSize(label4.getPreferredSize());
  335.                     label4.setLocation(160,132);
  336.                     label4.setToolTipText(
  337.         "For password,dept operations,please click on the left button");
  338.                     c.add(label4);
  339.  
  340.                     label4a = new JLabel("TRANSACTIONS");
  341.                     label4a.setPreferredSize(new Dimension(100,50));
  342.                             label4a.setSize(label4a.getPreferredSize());
  343.                     label4a.setLocation(160,148);
  344.                     c.add(label4a);
  345.  
  346.                       label5 = new JLabel("  INVESTMENT");
  347.                       label5.setPreferredSize(new Dimension(95,50));
  348.                       label5.setSize(label5.getPreferredSize());
  349.                       label5.setLocation(280,90);
  350.                       label5.setToolTipText(
  351.         "To buy fund,bond etc.,please click on the right button");
  352.                       c.add(label5);
  353.  
  354.                     label6 = new JLabel("  STANDARD");
  355.                     label6.setPreferredSize(new Dimension(75,50));
  356.                     label6.setSize(label6.getPreferredSize());
  357.                     label6.setLocation(280,132);
  358.                     label6.setToolTipText("To get 10$ rapidly,please click");
  359.                     c.add(label6);
  360.  
  361.                     label6a = new JLabel("  CASH");
  362.                     label6a.setPreferredSize(new Dimension(75,50));
  363.                     label6a.setSize(label6a.getPreferredSize());
  364.                     label6a.setLocation(280,147);
  365.                     label6a.setToolTipText("To get 10$ rapidly please click");
  366.                     c.add(label6a);
  367.  
  368.                       setSize(500,410) ;
  369.                       show();
  370.             }
  371.                 //------actionPerformed method for ActionListener-----
  372.                 public void actionPerformed( ActionEvent event ){
  373.                     if( event.getSource()==but7 )
  374.                             System.exit(0) ;
  375.                         else if( event.getSource() == but1 ){
  376.                             new Cash();this.hide();}
  377.                         else if(event.getSource()== but2 ){
  378.                             new Transfer();this.hide();}
  379.                         else if(event.getSource()==but3){
  380.                             new CardTransactions();this.hide();}
  381.                         else if(event.getSource()==but4 ){
  382.                             new Information();this.hide();}
  383.                         else if(event.getSource()==but6){
  384.                             new StandardCash();this.hide();}
  385.                         else if(event.getSource()==but9)
  386.                             System.exit(0);
  387.                         else if(event.getSource()==but8){
  388.                                 //----Select operation for  comparison of first password entered----
  389.                             try{
  390.                                     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  391.                                 }catch(ClassNotFoundException a){
  392.                                         JOptionPane.showMessageDialog(
  393.             null, url,"CLASS NOT FOUND EXCEPTION !!!",
  394.             JOptionPane.INFORMATION_MESSAGE);
  395.                                     }
  396.  
  397.                             try{
  398.                                     String string = new String(pwordfield.getPassword());
  399.                     intt=Integer.parseInt(string);
  400.                                 String run = "SELECT * FROM abc " +"WHERE password = " +intt;
  401.                                 System.out.println(run + "SQL string executed");
  402.                                 Connection connection = DriverManager.getConnection(url,"","");
  403.                                 Statement stmt = connection.createStatement();
  404.                                 ResultSet result=stmt.executeQuery(run);
  405.                                     while(result.next()){
  406.                                 String name = result.getString(1);
  407.                                 String surname = result.getString(2);
  408.                                 int amount = result.getInt(3);
  409.                                 int password = result.getInt(4);
  410.                                 pw=password;
  411.  
  412.                                     }
  413.                                 connection.close();
  414.  
  415.                                     }catch(SQLException a){
  416.                             JOptionPane.showMessageDialog(
  417.                 null,url,"SQL EXCEPTION AT SELECT OPERATION",
  418.                 JOptionPane.INFORMATION_MESSAGE);
  419.                     }               this.hide();
  420.                         //---Comparison---if there is not equivalent MainMenu does not appear-----
  421.                            if(pw==intt){MainMenu s=new MainMenu();s.Main();}
  422.                        else if(pw!=intt){
  423.                             JOptionPane.showMessageDialog(
  424.         null,"Invalid Password,Please try again",
  425.         "EXCEPTION",JOptionPane.ERROR_MESSAGE);
  426.                                 MainMenu s=new MainMenu();s.Password();
  427.                            }
  428.                         }
  429.  
  430.                 }//-----method main---Executes the password asking--------
  431.                 public static void main(String args[]){
  432.                      MainMenu s=new MainMenu();
  433.                          s.Password();
  434.                 }//-----password method----------
  435.                 public void Password(){
  436.                          c = getContentPane() ;
  437.                          c.setLayout(new FlowLayout()) ;
  438.                          c.setBackground(Color.lightGray);
  439.  
  440.                      pwordfield=new JPasswordField(17);
  441.                          c.add(pwordfield);
  442.  
  443.                          but8=new JButton("OK");
  444.                          but8.setPreferredSize(new Dimension(90,25));
  445.                          but8.setSize(but8.getPreferredSize());
  446.                          but8.addActionListener(this);
  447.                          c.add(but8);
  448.  
  449.                          but9=new JButton("CANCEL");
  450.                          but9.setPreferredSize(new Dimension(90,25));
  451.                          but9.setSize(but9.getPreferredSize());
  452.                          but9.addActionListener(this);
  453.                          c.add(but9);
  454.                          //-----Informations about the program-----
  455.                          String sttr="              W E L C O M E!\n"+
  456.                                  "    Please write your password:\n"+
  457.                                      "----------------------------------------------\n"+
  458.                                  "            This product is a\n"+
  459.                                  "       guarenteed trade mark of\n"+
  460.                                      " 'SP COMPUTER SYSTEMS INC.\n"+
  461.                                      "  For information we are on web:\n"+
  462.                                      "         www.spcomputer.com\n"+
  463.                                      "----------------------------------------------\n"+
  464.                                      "        Producer:  Ã–NER  EKIZ";
  465.  
  466.                          //-----set up textarea----------------
  467.                          textarea = new JTextArea(sttr,10,17);
  468.                          c.add(new JScrollPane(textarea));
  469.                          textarea.setBackground(Color.lightGray);
  470.                          textarea.setEditable(false);
  471.                          setSize(250,300) ;
  472.                          show();
  473.                }
  474.         }
  475.  
  476.  
  477.  
  478.  
  479.  
  480. ///DATABASE
  481.  
  482.  
  483. import java.awt.*;            //
  484. import java.awt.event.*;     //    PACKAGES
  485. import javax.swing.*;       //
  486. import java.sql.*;         //
  487.  
  488. public class DB extends JFrame implements ActionListener {
  489.         static String url = "jdbc:odbc:abc";
  490.         private JTextField text1,text2,text3;
  491.         private JButton but1,but2,but3,but4;
  492.         private JLabel label1,label2,label3;
  493.         private int Amount,Amount1,pword,int1;
  494.         private String str1,str2,str3;
  495.         private String run;
  496.         Container c;
  497.         //---Constructor---
  498.         public DB(){
  499.         }//---Method for getting different amount--called from class Cash--
  500.         public void ExecutionForAnother(){
  501.  
  502.                Container c=getContentPane();
  503.                c.setLayout(new FlowLayout());
  504.  
  505.                label2=new JLabel("   Write the money you want to get and your password:");
  506.                c.add(label2);
  507.                text1=new JTextField(10);
  508.                c.add(text1);
  509.  
  510.                label1=new JLabel("<<P.WORD||AMOUNT>>");
  511.                c.add(label1);
  512.                text2=new JTextField(10);
  513.                c.add(text2);
  514.  
  515.                but1=new JButton(" OK ");
  516.                but1.addActionListener(this);
  517.                but1.setBackground(Color.white);
  518.                c.add(but1);
  519.  
  520.                but4=new JButton(" BACK ");
  521.                but4.addActionListener(this);
  522.                but4.setBackground(Color.white);
  523.                c.add(but4);
  524.  
  525.                setSize(400,250);
  526.                setResizable(true);
  527.                show();
  528.         }//----Method for getting one of the value(money) that is seen
  529.         //---on the screen--Called from class Cash---
  530.         public void CashScreen(){
  531.                c=getContentPane();
  532.                c.setLayout(new FlowLayout());
  533.  
  534.                label3 = new JLabel("PLEASE WRITE Pword & PRESS OK:");
  535.                c.add(label3);
  536.                text3=new JTextField(10);
  537.                c.add(text3);
  538.  
  539.                but2 = new JButton("OK");
  540.                but2.setPreferredSize(new Dimension(80,25));
  541.                but2.setSize(but2.getPreferredSize());
  542.                but2.setBackground(Color.white);
  543.                but2.addActionListener(this);
  544.                c.add(but2);
  545.  
  546.                but3 = new JButton("CANCEL");
  547.                but3.setPreferredSize(new Dimension(80,25));
  548.                but3.setSize(but3.getPreferredSize());
  549.                but3.setBackground(Color.white);
  550.                but3.addActionListener(this);
  551.                c.add(but3);
  552.  
  553.                setSize(350,200);
  554.                show();
  555.         }//--------Method for  the ActionListener---------
  556.         public void actionPerformed(ActionEvent event){
  557.                    if(event.getSource()==but2){// for CashScreen
  558.                             str3=text3.getText();
  559.                             int int8=Integer.parseInt(str3);
  560.                         try{    //--Selection for CashScreen---
  561.                             String run =  "SELECT * FROM abc  " +"WHERE password=" +int8;
  562.                             System.out.println(run+"SQL Operatýon Executed..");
  563.                             Connection connection = DriverManager.getConnection(url,"","");
  564.                             Statement stmt = connection.createStatement();
  565.                             ResultSet result=stmt.executeQuery(run);
  566.                               while (result.next()){
  567.                             String name = result.getString(1);
  568.                             String surname = result.getString(2);
  569.                             int amount = result.getInt(3);
  570.                             int password = result.getInt(4);
  571.                             Amount = amount;
  572.                               }
  573.                               connection.close();
  574.                              }catch(SQLException a){
  575.                                 JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECTION OPERATION",JOptionPane.INFORMATION_MESSAGE);
  576.                          }
  577.                             Amount=Amount-20; //reducing the user's money
  578.                                 //---Updating the new values----
  579.                             String run1 =  "UPDATE abc SET " +
  580.                             "amount='" +Amount+"' WHERE password="+int8;
  581.                         try{
  582.                             Connection connection = DriverManager.getConnection(url,"","");
  583.                             Statement stmt = connection.createStatement();
  584.                             stmt.executeUpdate(run1);
  585.                             System.out.println("Operation completed...");
  586.                             connection.close();
  587.                             }catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
  588.                             }
  589.  
  590.  
  591.                    }//--------------------------------------------------------
  592.                    else if(event.getSource()==but4){
  593.                         this.hide();}
  594.                    else if(event.getSource()==but1){ //for another
  595.                         str2=text1.getText();  // gets password
  596.                                 pword=Integer.parseInt(str2);
  597.                         try{
  598.                             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  599.                             }catch(ClassNotFoundException a){
  600.                                 JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
  601.                             }
  602.             //---Selection for ExecutionForAnother----
  603.                         try{
  604.                             String run = "SELECT * FROM abc " +"WHERE password = " +pword;
  605.                             System.out.println(run + "SQL string executed");
  606.                             Connection connection = DriverManager.getConnection(url,"","");
  607.                             Statement stmt = connection.createStatement();
  608.                             ResultSet result=stmt.executeQuery(run);
  609.                               while(result.next()){
  610.                             String name = result.getString(1);
  611.                             String surname = result.getString(2);
  612.                             int amount = result.getInt(3);
  613.                             int password = result.getInt(4);
  614.  
  615.                             Amount1=amount;
  616.                             }
  617.                             connection.close();
  618.                             }catch(SQLException a){
  619.                                 JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
  620.                             }
  621.                             str1=text2.getText(); //gets the wanted money
  622.                             int1 =Integer.parseInt(str1);
  623.                             Amount1=Amount1-int1; //and subtract it from the total money
  624.                                 //--Update the Amount after operations above--
  625.                             String run1 =  "UPDATE abc SET " +
  626.                             "amount='" +Amount1+"' WHERE password="+pword;
  627.                         try{
  628.                             Connection connection = DriverManager.getConnection(url,"","");
  629.                             Statement stmt = connection.createStatement();
  630.                             stmt.executeUpdate(run1);
  631.                             System.out.println("Operation completed...");
  632.                             connection.close();
  633.                             }catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
  634.                             }
  635.                    }
  636.                    else if(event.getSource()==but3){
  637.                         this.hide();
  638.                    }
  639.         }//--end of method actionPerformed---
  640.  
  641. }//--end of class.
  642.  
  643.  
  644. ///database2
  645.  
  646.  
  647. import java.awt.*;             //
  648. import java.awt.event.*;      //    PACKAGES
  649. import javax.swing.*;        //
  650. import java.sql.*;          //
  651.  
  652.    public class DB2 extends JFrame implements ActionListener{
  653.           private JTextField text1,text2,text3,text4,text5,text6,text7;
  654.           private JButton but1,but2,but3,but4,but5,but6,but7,button1,button2;
  655.           private JLabel label,label1,label2,label3,label4,label5,label6;
  656.           private String str1,str2,str3,str4,str5,str6,str7;
  657.           private int Amount,Password,Depts,password2;
  658.           protected JList list1,list2;
  659.           private String depts[]={"Renting dept","Receipt dept","Credit depts",
  660.                 "Education depts","Insurance depts","Comunication depts",
  661.                         "Car depts","Home depts","Security depts.."};
  662.           static String url = "jdbc:odbc:abc";
  663.           Container c;
  664.           //---Constructor---
  665.           public DB2(){
  666.                  super("Executions");
  667.           }//--Method for changing password--called from class CardTransactions--
  668.           public void ChangePword(){
  669.                  c=getContentPane();
  670.                  c.setLayout(null);
  671.  
  672.                  but1=new JButton(" OK ");
  673.                  but1.addActionListener(this);
  674.                  but1.setPreferredSize(new Dimension(80,23));
  675.                  but1.setSize(but1.getPreferredSize());
  676.                  but1.setLocation(200,180);
  677.                  but1.setBackground(Color.white);
  678.                  c.add(but1);
  679.  
  680.                  but3=new JButton("CANCEL");
  681.                  but3.addActionListener(this);
  682.                  but3.setPreferredSize(new Dimension(80,22));
  683.                  but3.setSize(but3.getPreferredSize());
  684.                  but3.setLocation(100,180);
  685.                  but3.setBackground(Color.white);
  686.                  c.add(but3);
  687.  
  688.                  text1=new JTextField(10);
  689.                  text1.setPreferredSize(new Dimension(10,22));
  690.                  text1.setSize(text1.getPreferredSize());
  691.                  text1.setLocation(200,50);
  692.                  str1=text1.getText();
  693.                  c.add(text1);
  694.  
  695.                  text2=new JTextField(10);
  696.                  text2.setPreferredSize(new Dimension(10,22));
  697.                  text2.setSize(text2.getPreferredSize());
  698.                  text2.setLocation(200,100);
  699.                  str2=text2.getText();
  700.                  c.add(text2);
  701.  
  702.                  label1=new JLabel("Enter your OLD password:");
  703.                  label1.setPreferredSize(new Dimension(150,30));
  704.                  label1.setSize(label1.getPreferredSize());
  705.                  label1.setLocation(33,46);
  706.                  c.add(label1);
  707.  
  708.                  label2=new JLabel("Enter your NEW password:");
  709.                  label2.setPreferredSize(new Dimension(160,30));
  710.                  label2.setSize(label2.getPreferredSize());
  711.                  label2.setLocation(33,96);
  712.                  c.add(label2);
  713.  
  714.                  setSize(350,300);
  715.                  setResizable(true);
  716.                  show();
  717.           }//--Method for DeptPaying--called from class CardTransactions--
  718.           public void DeptPaying(){
  719.                  c=getContentPane();
  720.                  c.setLayout(new FlowLayout());
  721.  
  722.                  list1 =new JList(depts);
  723.                  list1.setVisibleRowCount(5);
  724.                  list1.setFixedCellHeight(15);
  725.                  list1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  726.                  c.add(new JScrollPane(list1));
  727.  
  728.                  list2 =new JList();
  729.                  list2.setVisibleRowCount(4);
  730.                  list2.setFixedCellWidth(100);
  731.                  list2.setFixedCellHeight(18);
  732.                  list2.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
  733.                  c.add(new JScrollPane(list2));
  734.  
  735.                  label5=new JLabel("Enter your password:");
  736.                  c.add(label5);
  737.                  text6=new JTextField(15);
  738.                  c.add(text6);
  739.  
  740.                  label6=new JLabel("Your dept to pay:");
  741.                  c.add(label6);
  742.                  text7=new JTextField(15);
  743.                  c.add(text7);
  744.  
  745.                  but2=new JButton(" OK ");
  746.                  but2.setBackground(Color.white);
  747.                  but2.setPreferredSize(new Dimension(100,20));
  748.                  but2.setSize(but2.getPreferredSize());
  749.                  but2.addActionListener(this);
  750.                  c.add(but2);
  751.  
  752.                  but4=new JButton(" Cancel ");
  753.                  but4.addActionListener(this);
  754.                  but4.setPreferredSize(new Dimension(100,20));
  755.                  but4.setSize(but4.getPreferredSize());
  756.                  but4.setBackground(Color.white);
  757.                  c.add(but4);
  758.  
  759.  
  760.                  setSize(370,200);
  761.                  setVisible(true);
  762.           }//----Method for ActionListener-------
  763.           public void actionPerformed(ActionEvent event){
  764.  
  765.                   if(event.getSource()==but1){
  766.                         //--Getting the values which will be changed--
  767.                         str1=text1.getText();
  768.                         str2=text2.getText();
  769.                                 //--Updating the values of password changing--
  770.                             String run =  "UPDATE abc SET " +
  771.                             "password='" +str2+"' WHERE password="+str1;
  772.                         try{
  773.                             Connection connection = DriverManager.getConnection(url,"","");
  774.                             Statement stmt = connection.createStatement();
  775.                             stmt.executeUpdate(run);
  776.                             System.out.println("Operation completed...");
  777.                             connection.close();
  778.                             }catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
  779.                             }
  780.                   }
  781.                   //---Select operation for the DeptPaying method----
  782.                   else if(event.getSource()==but2){
  783.                     int int6;int int7;Depts=0;
  784.                         list2.setListData(list1.getSelectedValues());
  785.  
  786.                         try{
  787.                             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  788.                             }catch(ClassNotFoundException a){
  789.                                 JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
  790.                             }
  791.  
  792.                         try{
  793.                             str6=text6.getText();
  794.                             int6=Integer.parseInt(str6);
  795.                             String run = "SELECT * FROM abc " +"WHERE password = " +int6;
  796.                             System.out.println(run + "SQL string executed");
  797.                             Connection connection = DriverManager.getConnection(url,"","");
  798.                             Statement stmt = connection.createStatement();
  799.                             ResultSet result=stmt.executeQuery(run);
  800.                               while(result.next()){
  801.                             String name = result.getString(1);
  802.                             String surname = result.getString(2);
  803.                             int amount = result.getInt(3);
  804.                             int password = result.getInt(4);
  805.                             int depts =result.getInt(5);
  806.                             password2=password;
  807.                             Depts=depts;
  808.                               }
  809.                                 connection.close();
  810.                               }catch(SQLException a){
  811.                                 JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
  812.                               }
  813.                             int6=password2;
  814.                             str7=text7.getText();
  815.                             int7=Integer.parseInt(str7);
  816.                             Depts=Depts-int7;
  817.                                 //---Update operation for DeptPaying----
  818.                             String run4 =  "UPDATE abc SET " +
  819.                             "depts='" +Depts+"' WHERE password="+int6;
  820.                         try{
  821.                             Connection connection = DriverManager.getConnection(url,"","");
  822.                             Statement stmt = connection.createStatement();
  823.                             stmt.executeUpdate(run4);
  824.                             System.out.println("Operation completed...");
  825.                             connection.close();
  826.                             }catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
  827.                             }
  828.                   }
  829.                   //--------------------------------------------------------------
  830.  
  831.                   else if(event.getSource()==but3){
  832.                     this.hide();}
  833.                   else if(event.getSource()==but4){
  834.                         this.hide();
  835.                   }
  836.                   else if(event.getSource()==but7){
  837.                         this.hide();}
  838.                  //----Select operation for Demonstration-------------------------
  839.                  else if(event.getSource()==but6){
  840.                          try{
  841.                             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  842.                              }catch(ClassNotFoundException a){
  843.                                 JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
  844.                              }
  845.                           try{
  846.                             str5=text5.getText();
  847.                             int pword=Integer.parseInt(str5);
  848.  
  849.                             String run = "SELECT * FROM abc " +"WHERE password = " +pword;
  850.                             System.out.println(run + "SQL string executed");
  851.                             Connection connection = DriverManager.getConnection(url,"","");
  852.                             Statement stmt = connection.createStatement();
  853.                             ResultSet result=stmt.executeQuery(run);
  854.                               while(result.next()){
  855.                             String name = result.getString(1);
  856.                             String surname = result.getString(2);
  857.                             String amount = result.getString(3);
  858.                             String password = result.getString(4);
  859.                             JOptionPane.showMessageDialog(null,"Your total money is: "+amount+"$");
  860.                               }
  861.                             connection.close();
  862.                               }
  863.                               catch(SQLException a){
  864.                                 JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
  865.                               }
  866.  
  867.                  }//--Closing the actionPerformed method--
  868.           }//--Method for the
  869.           public void Back(){
  870.              this.hide();
  871.                  MainMenu s=new MainMenu();
  872.                  s.Main();
  873.           }
  874.           public void Demonstration(){
  875.                  c = getContentPane();
  876.                  c.setLayout(new FlowLayout());
  877.  
  878.                  label4=new JLabel("To see remainder,write your password ");
  879.                  c.add(label4);
  880.  
  881.                  text5=new JTextField(10);
  882.                  c.add(text5);
  883.  
  884.                  but6 = new JButton("OK");
  885.                  but6.addActionListener(this);
  886.                  c.add(but6);
  887.  
  888.                  but7 = new JButton("BACK");
  889.                  but7.addActionListener(this);
  890.                  c.add(but7);
  891.  
  892.                  setSize(350,200);
  893.                  setResizable(true);
  894.                  show();
  895.           }
  896. }
  897.  
  898.  
  899. ///information
  900.  
  901. import java.awt.*;           //
  902. import java.awt.event.*;    //  PACKAGES
  903. import javax.swing.*;      //
  904. import java.sql.*;        //
  905. public class Information extends JFrame implements ActionListener {
  906.        private JButton button1,button2;
  907.        private JLabel label1,label2;
  908.        static String url = "jdbc:odbc:abc";
  909.        //-----Constructor------
  910.        public Information(){
  911.               super();
  912.               Container container = getContentPane();
  913.               container.setLayout(null);
  914.  
  915.               button1 = new JButton(" >>> ");
  916.               button1.setPreferredSize(new Dimension(100,30));
  917.               button1.setSize(button1.getPreferredSize());
  918.               button1.setLocation(30,50);
  919.               button1.addActionListener(this);
  920.               container.add(button1);
  921.  
  922.               button2 = new JButton(" CANCEL ");
  923.               button2.setPreferredSize(new Dimension(100,30));
  924.               button2.setSize(button2.getPreferredSize());
  925.               button2.setLocation(30,100);
  926.               button2.addActionListener(this);
  927.               container.add(button2);
  928.  
  929.               label1 = new JLabel("Demonstration");
  930.               label1.setPreferredSize(new Dimension(120,30));
  931.               label1.setSize(label1.getPreferredSize());
  932.               label1.setLocation(150,43);
  933.               container.add(label1);
  934.  
  935.               label2 = new JLabel("of Remainder");
  936.               label2.setPreferredSize(new Dimension(120,30));
  937.               label2.setSize(label2.getPreferredSize());
  938.               label2.setLocation(150,56);
  939.               container.add(label2);
  940.  
  941.               setSize(400,300);
  942.               setVisible(true);
  943.        }//------actionPerformed method for ActionListener-----
  944.        public void actionPerformed(ActionEvent event){
  945.  
  946.               if(event.getSource()==button1){
  947.                     DB2 s=new DB2();s.Demonstration();
  948.               }
  949.               else if(event.getSource()==button2){
  950.                         //--Closes the present window--
  951.                     this.hide();
  952.                         //--Going to DB2 class for execution
  953.                     DB2 s=new DB2();s.Back();
  954.               }
  955.        }
  956.  
  957. }
  958.  
  959.  
  960. ///standard cash
  961.  
  962.  
  963. import java.awt.*;            //
  964. import java.awt.event.*;     //  PACKAGES
  965. import javax.swing.*;       //
  966. import java.sql.*;         //
  967.        public class StandardCash extends JFrame implements ActionListener {
  968.               private JButton button1,button2;
  969.               private JLabel label1;
  970.               private String str1;
  971.               private int Amount,Password;
  972.               private JTextField text1;
  973.               static String url = "jdbc:odbc:abc";
  974.               Container container;
  975.               //SET UP GUI
  976.               public StandardCash(){
  977.                      super("Standard Cash (10$)");
  978.                      Container container = getContentPane();
  979.                      container.setLayout(null);
  980.  
  981.                      button1 = new JButton("OK");
  982.                      button1.setPreferredSize(new Dimension (90,30));
  983.                      button1.setSize(button1.getPreferredSize());
  984.                      button1.setLocation(50,100);
  985.                      button1.addActionListener(this);
  986.                      container.add(button1);
  987.  
  988.                      text1=new JTextField(10);
  989.                      text1.setPreferredSize(new Dimension(10,22));
  990.                      text1.setSize(text1.getPreferredSize());
  991.                      text1.setLocation(50,60);
  992.                      container.add(text1);
  993.  
  994.                      button2 = new JButton("CANCEL");
  995.                      button2.setPreferredSize(new Dimension (90,30));
  996.                      button2.setSize(button2.getPreferredSize());
  997.                      button2.addActionListener(this);
  998.                      button2.setLocation(150,100);
  999.  
  1000.                      container.add(button2);
  1001.  
  1002.                      label1 = new JLabel("Please enter your password:");
  1003.                      label1.setPreferredSize(new Dimension(250,20));
  1004.                      label1.setSize(label1.getPreferredSize());
  1005.                      label1.setLocation(50,40);
  1006.                      container.add(label1);
  1007.  
  1008.                      setSize(350,300);
  1009.                      show();
  1010.  
  1011.               }//------Method for ActionListener-----------------
  1012.               public void actionPerformed(ActionEvent event){
  1013.                 if(event.getSource()==button1){
  1014.                         //Selecting the values for the user--------
  1015.                         try{
  1016.                             str1=text1.getText();
  1017.                                 int int1=Integer.parseInt(str1);
  1018.  
  1019.                             String run = "SELECT * FROM abc " +"WHERE password = " +int1;
  1020.                             System.out.println(run + "SQL string executed");
  1021.                             Connection connection = DriverManager.getConnection(url,"","");
  1022.                             Statement stmt = connection.createStatement();
  1023.                             ResultSet result=stmt.executeQuery(run);
  1024.                               while(result.next()){
  1025.                             String name = result.getString(1);
  1026.                             String surname = result.getString(2);
  1027.                             int amount = result.getInt(3);
  1028.                             int password = result.getInt(4);
  1029.                             Password=password;
  1030.                             Amount=amount-10;
  1031.                               }
  1032.                             connection.close();
  1033.                             }
  1034.                             catch(SQLException a){
  1035.                                 JOptionPane.showMessageDialog(
  1036.         null,url,"SQL EXCEPTION AT SELECT OPERATION",
  1037.         JOptionPane.INFORMATION_MESSAGE);
  1038.                             }
  1039.                                 //-----Updating the Amount that is reduced up ^^----------
  1040.                             String run =  "UPDATE abc SET " +
  1041.                             "amount='" +Amount+"' WHERE password="+Password;
  1042.                         try{
  1043.                             Connection connection = DriverManager.getConnection(url,"","");
  1044.                             Statement stmt = connection.createStatement();
  1045.                             stmt.executeUpdate(run);
  1046.                             System.out.println("Operation completed...");
  1047.                             connection.close();
  1048.                             }catch(SQLException a){JOptionPane.showMessageDialog(
  1049.                 null,url,"SQL EXCEPTION AT UPDATE OPERATION",
  1050.                 JOptionPane.INFORMATION_MESSAGE);
  1051.                             }
  1052.                         }
  1053.                         else if(event.getSource()==button2){
  1054.                             this.hide();
  1055.                                 MainMenu s=new MainMenu();s.Main();
  1056.                         }
  1057.  
  1058.               }
  1059.     }
  1060.  
  1061.  
  1062.  
  1063. ////transfer
  1064.  
  1065. import java.awt.*;               //
  1066. import java.awt.event.*;        //
  1067. import javax.swing.*;          //  PACKAGES
  1068. import java.sql.*;            //
  1069. import sun.jdbc.odbc.*;      //
  1070.  
  1071.     public class Transfer extends JFrame implements ActionListener{
  1072.             private JTextField textfield1,textfield2,textfield3,textfield4,textfield5;
  1073.             private JButton OKButton,ExitButton;
  1074.             private JLabel label;
  1075.             private int int1,int2,int3,Amount,Amount1,Password;
  1076.             private String str1,str2,str3;
  1077.             static String url = "jdbc:odbc:abc";
  1078.                 //SET UP GUI
  1079.             public Transfer(){
  1080.                 super("Money Transfer");
  1081.                 Container container = getContentPane();
  1082.                 container.setLayout(new FlowLayout() );
  1083.  
  1084.                 label=new JLabel("Password of the user:");
  1085.                 label.setLocation(200,50);
  1086.                 container.add(label);
  1087.  
  1088.                 textfield5 = new JTextField(15);
  1089.                 container.add(textfield5);
  1090.  
  1091.                 textfield1 = new JTextField("Password of the receiver:");
  1092.                 textfield1.setEditable(false);
  1093.                 container.add(textfield1);
  1094.                         textfield2 = new JTextField(15);
  1095.                 container.add(textfield2);
  1096.  
  1097.                     textfield3 = new JTextField("Amount of the sent:",15);
  1098.                     textfield3.setEditable(false);
  1099.                     container.add(textfield3);
  1100.                     textfield4 = new JTextField(15);
  1101.                     container.add(textfield4);
  1102.  
  1103.                     OKButton = new JButton("OK");
  1104.                     OKButton.setPreferredSize(new Dimension(80,20));
  1105.                     OKButton.setSize(OKButton.getPreferredSize());
  1106.                     OKButton.addActionListener(this);
  1107.                     container.add(OKButton);
  1108.  
  1109.                     ExitButton = new JButton("Exit");
  1110.                     ExitButton.setPreferredSize(new Dimension(80,20));
  1111.                     ExitButton.setSize(ExitButton.getPreferredSize());
  1112.                     ExitButton.addActionListener(this);
  1113.                     container.add(ExitButton);
  1114.  
  1115.                     setSize(400,150);
  1116.                     setVisible(true);
  1117.  
  1118.             }//-------------actionPerformed----------------------------------------
  1119.             public void actionPerformed(ActionEvent event){
  1120.                     if(event.getSource()==ExitButton){
  1121.                         this.hide();MainMenu s=new MainMenu();s.Main();
  1122.                         }
  1123.                 else if(event.getSource()==OKButton){
  1124.                         try{
  1125.                             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  1126.                             }catch(ClassNotFoundException a){
  1127.                                 JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
  1128.                             }
  1129.                         }
  1130.                         try{    //Select operation:
  1131.                             str3=textfield5.getText();   // gets password of user
  1132.                             int1=Integer.parseInt(str3);
  1133.                             String run = "SELECT * FROM abc " +"WHERE password = " +int1;
  1134.                             System.out.println(run + "SQL string executed");
  1135.                             Connection connection = DriverManager.getConnection(url,"","");
  1136.                             Statement stmt = connection.createStatement();
  1137.                             ResultSet result=stmt.executeQuery(run);
  1138.                               while(result.next()){
  1139.                             String name = result.getString(1);
  1140.                             String surname = result.getString(2);
  1141.                             int amount = result.getInt(3);
  1142.                             int password = result.getInt(4);
  1143.  
  1144.                             Amount=amount;
  1145.                               }
  1146.                             connection.close();
  1147.                             }
  1148.                             catch(SQLException a){
  1149.                                 JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
  1150.                             }
  1151.  
  1152.                             str2=textfield4.getText();  //amount of sent
  1153.                             int3=Integer.parseInt(str2);
  1154.                             Amount=Amount-int3;
  1155.                                 //--------------Updating values of the database-------------
  1156.                             String run =  "UPDATE abc SET " +
  1157.                             "amount='" +Amount+"' WHERE password="+int1;
  1158.                         try{
  1159.                             Connection connection = DriverManager.getConnection(url,"","");
  1160.                             Statement stmt = connection.createStatement();
  1161.                             stmt.executeUpdate(run);
  1162.                             System.out.println("Operation completed...");
  1163.                             connection.close();
  1164.                             }catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
  1165.                             }
  1166.                         //---Select operation for the person (the money transferred to)------
  1167.                         try{
  1168.                             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  1169.                             }catch(ClassNotFoundException a){
  1170.                                 JOptionPane.showMessageDialog(null, url,"CLASS NOT FOUND EXCEPTION !!!",JOptionPane.INFORMATION_MESSAGE);
  1171.                             }
  1172.                         try{
  1173.                             str1=textfield2.getText();//password of receiver
  1174.                             int2=Integer.parseInt(str1);
  1175.  
  1176.                             String run2 = "SELECT * FROM abc " +"WHERE password = " +int2;
  1177.                             System.out.println(run2 + "SQL string executed");
  1178.                             Connection connection = DriverManager.getConnection(url,"","");
  1179.                             Statement stmt = connection.createStatement();
  1180.                             ResultSet result=stmt.executeQuery(run2);
  1181.                               while(result.next()){
  1182.                             String name = result.getString(1);
  1183.                             String surname = result.getString(2);
  1184.                             int amount = result.getInt(3);
  1185.                             int password = result.getInt(4);
  1186.  
  1187.                             Amount1=amount;
  1188.                               }
  1189.                             connection.close();
  1190.                             }
  1191.                             catch(SQLException a){
  1192.                                 JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT SELECT OPERATION",JOptionPane.INFORMATION_MESSAGE);
  1193.                             }
  1194.                             Amount1=Amount1+int3;
  1195.                                 //---------Updating the values for the person,money transferred to--
  1196.                             String run1 =  "UPDATE abc SET " +
  1197.                             "amount='" +Amount1+"' WHERE password="+int2;
  1198.                         try{
  1199.                             Connection connection = DriverManager.getConnection(url,"","");
  1200.                             Statement stmt = connection.createStatement();
  1201.                             stmt.executeUpdate(run1);
  1202.                             System.out.println("Operation completed...");
  1203.                             connection.close();
  1204.                             }catch(SQLException a){JOptionPane.showMessageDialog(null,url,"SQL EXCEPTION AT UPDATE OPERATION",JOptionPane.INFORMATION_MESSAGE);
  1205.                             }
  1206.  
  1207.         }
  1208.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement