AllFreePapers.com - All Free Papers and Essays for All Students
Search

Database Connectivity

Autor:   •  August 27, 2015  •  Book/Movie Report  •  643 Words (3 Pages)  •  825 Views

Page 1 of 3

String name=jTextField1.getText();

        String email=jTextField2.getText();

        String mobile=jTextField3.getText();

        if(name.isEmpty()) {

            JOptionPane.showMessageDialog(this, "Name not Entered");

        }

        else if(email.isEmpty()) {

            JOptionPane.showMessageDialog(this, "Email not Entered");

        }

        else if(mobile.isEmpty()) {

            JOptionPane.showMessageDialog(this, "Mobile not Entered");

        }

        else{

        try{

            Class.forName("java.sql.DriverManager");

            Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/pk", "root", "1234");

            Statement stmt=con.createStatement();

            String query="insert into contactdiary values('"+name+"','"+email+"','"+mobile+"');";

            stmt.executeUpdate(query);

            JOptionPane.showMessageDialog(this, "Account added successfully.");

        }

        catch(Exception e){

            JOptionPane.showMessageDialog(this, e.getMessage());

        }

        }

Add account

  String name=jTextField1.getText();

        int accno=Integer.parseInt(jTextField2.getText());

       int deposit=Integer.parseInt(jTextField3.getText());

       String address=jTextField4.getText();

       String date=jTextField4.getText();

     

        if(name.isEmpty()) {

            JOptionPane.showMessageDialog(this, "Name not Entered");

        }

        else if(accno==0) {

            JOptionPane.showMessageDialog(this, "Email not Entered");

        }

        else if(deposit==0) {

            JOptionPane.showMessageDialog(this, "Deposit not Entered");

...

Download as:   txt (2.5 Kb)   pdf (36.5 Kb)   docx (5 Kb)  
Continue for 2 more pages »