Friday 20 April 2018

create a Derby databse project as desktop application phone directory and download source code

phone directory derby database and java projects

create a Derby  database project as desktop application phone directory
before creating desktop application understand what is derby data base
and what importance of java programming and what value of derby database
in java programming and why important phone directory desktop application
is important .
Computer application made by accurate programming language.
software techniques provide one way solution based on computer
programming language.every software made by some source codes
that is write in programming language after testing source change
in binary code that is a software application .software application
responsible for some import task that developed by an computer
language.The aim of this tutorial is to develop people do computer
program us a computer langu1.


Derby  Database is the choice of computer programming to create simple application software.
Derby database works more easily with Java programs language.
 Derby database is based on open source code and provides small footprint and standards based database engine that can be tightly embedded into any java based solution.
It is available with many versions Apache  Technology Through this, many types of data best applications are created.
 It is used to create two types of databases . An application which is based on single computer machine And in the other the clients that are based on the server architecture.
 Derby is used in different operating system software with different configurations
 Use command prompt for its settings.
This database works with different operating system software such as Windows Unix Linux . Here's a general method to build your application based on embedded method.
What is shown in the Java program based on that data base.
 How Databases Work for a Single Computer and Where Derby  can create an independent software application that can be used on a Windows based computer




how to make desk top  application from derby datase and java

step 1:
open NetBeans IDE  and create new project with phonedicectory
step 2: right clik at the project and add jframe with name main
step 3:creating GUI look like this.

step 4:open phonedicectory.java file and set main java file is visible is true.


  Main mm=new Main();
        mm.setVisible(true);
       mm.setSize(964,300);
     
step 5:open main in sourse code mode and some required  header files likes this
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.DatabaseMetaData;
import java.sql.Statement;
import java.sql.PreparedStatement;
import javax.swing.JOptionPane;

step 7:right click at libraries directory under phonedicectory project and click at add jar and  folder option and add some
derby tools like this
derby.jar
derbyclient.jar
derbynet.jar
derbyoptionltools.jar
derbyrun.jar
derbytool.jar
step8:clik at new ans save and next,search button do code acoding to affeter componet newworld

see code  phonedicectory
see conde amain .java
========================================================================phonedicectory.java      source code
========================================================================
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package phonedicectory;

/**
 *
 * @author rajesh kumar shukla
 */
public class Phonedicectory {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
     
        Main mm=new Main();
        mm.setVisible(true);
       mm.setSize(964,300);
     
     
    }
 
}
========================================================================
Main.java  source code
========================================================================/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package phonedicectory;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.DatabaseMetaData;
import java.sql.Statement;
import java.sql.PreparedStatement;
import javax.swing.JOptionPane;


/**
 *
 * @author rajesh kumar shukla
 */
public class Main extends javax.swing.JFrame {

    /**
     * Creates new form Main
     */
    
     Connection conn;
    ResultSet rs;
  
    Statement smt;
    DatabaseMetaData mymetadata;
PreparedStatement psd;


    public Main() {
        initComponents();
        doconnect();
    }

   public void doconnect()
{
    try
    {
       String Driver="org.apache.derby.jdbc.EmbeddedDriver";
       String mydata="phone";
       String url="jdbc:derby:"+mydata+";create=true";
               conn=DriverManager.getConnection(url);
               
         smt=conn.createStatement();
          DatabaseMetaData dbmd = conn.getMetaData();
rs = dbmd.getTables(null, null, "coll", null);


        String qurer="CREATE TABLE coll (ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), NAME VARCHAR(100) NOT NULL,MOB VARCHAR(11) NOT NULL)";
if(!rs.next()){
smt.executeUpdate(qurer);

}
rs.close();
smt.close();

smt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);


String query1="SELECT * FROM coll";
rs=smt.executeQuery(query1);
rs.next();

int uid=rs.getInt("ID");
String uuid=Integer.toString(uid);
jTextField5.setText(uuid);
String named=rs.getString("NAME");
String mom=rs.getString("MOB");
jTextField1.setText(named);
jTextField2.setText(mom);


    }
    catch(SQLException err)
    {
      JOptionPane.showMessageDialog(Main.this, err.getMessage());
    }
}
 /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jTextField5 = new javax.swing.JTextField();
        jButton11 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("PHONE DIRECTORY");
        setBounds(new java.awt.Rectangle(30, 30, 976, 300));
        setPreferredSize(new java.awt.Dimension(9680, 300));
        setResizable(false);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/phonedicectory/LOGO.png"))); // NOI18N

        jLabel1.setBackground(new java.awt.Color(255, 153, 102));
        jLabel1.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel1.setText("ENTER NAME");

        jLabel2.setBackground(new java.awt.Color(255, 153, 102));
        jLabel2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel2.setText("ENTER MOB NO.");

        jTextField1.setBackground(new java.awt.Color(255, 153, 102));
        jTextField1.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N

        jTextField2.setBackground(new java.awt.Color(255, 153, 102));
        jTextField2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N

        jLabel3.setBackground(new java.awt.Color(255, 153, 102));
        jLabel3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel3.setText("SEARCH BY NUMBER");

        jTextField3.setBackground(new java.awt.Color(255, 153, 102));
        jTextField3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N

        jLabel4.setBackground(new java.awt.Color(255, 153, 102));
        jLabel4.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel4.setText("SEARCH BY NAME");

        jTextField4.setBackground(new java.awt.Color(255, 153, 102));
        jTextField4.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N

        jButton2.setBackground(new java.awt.Color(255, 153, 102));
        jButton2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton2.setText("NEW");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setBackground(new java.awt.Color(255, 153, 102));
        jButton3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton3.setText("SAVE");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setBackground(new java.awt.Color(255, 153, 102));
        jButton4.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton4.setText("UPDATE");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setBackground(new java.awt.Color(255, 153, 102));
        jButton5.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton5.setText("DELETE");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setBackground(new java.awt.Color(255, 153, 102));
        jButton6.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton6.setText("NEXT");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setBackground(new java.awt.Color(255, 153, 102));
        jButton7.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton7.setText("previous");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton8.setBackground(new java.awt.Color(255, 153, 102));
        jButton8.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton8.setText("FRIST");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton9.setBackground(new java.awt.Color(255, 153, 102));
        jButton9.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton9.setText("LAST");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jButton10.setBackground(new java.awt.Color(255, 153, 102));
        jButton10.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton10.setText("SEARCH");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        jTextField5.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N

        jButton11.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jButton11.setText("SEARCH");
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTextField1)
                    .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 221, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton10)
                    .addComponent(jButton11))
                .addGap(19, 19, 19))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 958, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton9))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(470, 470, 470)
                        .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(5, 5, 5)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(27, 27, 27)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton10))
                        .addGap(34, 34, 34)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(jButton11))))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(jButton4)
                    .addComponent(jButton5)
                    .addComponent(jButton6)
                    .addComponent(jButton7)
                    .addComponent(jButton8)
                    .addComponent(jButton9))
                .addContainerGap(31, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
          try
    {
      


if(rs.next()){

int uid=rs.getInt("ID");
String uuid=Integer.toString(uid);
jTextField5.setText(uuid);

String named=rs.getString("NAME");
String mom=rs.getString("MOB");
jTextField1.setText(named);
jTextField2.setText(mom);
}
else{
    rs.previous();
      JOptionPane.showMessageDialog(Main.this, "start searching");
    
}
    }
    catch(SQLException err)
    {
      JOptionPane.showMessageDialog(Main.this, err.getMessage());
    }

    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
              try
    {
      


if(rs.previous()){

int uid=rs.getInt("ID");
String uuid=Integer.toString(uid);
jTextField5.setText(uuid);

String named=rs.getString("NAME");
String mom=rs.getString("MOB");
jTextField1.setText(named);
jTextField2.setText(mom);

}
else{
    rs.next();
      JOptionPane.showMessageDialog(Main.this, "end number");
    
}
    }
    catch(SQLException err)
    {
      JOptionPane.showMessageDialog(Main.this, err.getMessage());
    }
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
                  try
    {
      

String query1="SELECT * FROM coll";
rs=smt.executeQuery(query1);
if(rs.first()){

int uid=rs.getInt("ID");
String uuid=Integer.toString(uid);
jTextField5.setText(uuid);

String named=rs.getString("NAME");
String mom=rs.getString("MOB");
jTextField1.setText(named);
jTextField2.setText(mom);
}

    }
    catch(SQLException err)
    {
      JOptionPane.showMessageDialog(Main.this, err.getMessage());
    }
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
                  try
    {
      

String query1="SELECT * FROM coll";
rs=smt.executeQuery(query1);
if(rs.last()){
int uid=rs.getInt("ID");
String uuid=Integer.toString(uid);
jTextField5.setText(uuid);

String named=rs.getString("NAME");
String mom=rs.getString("MOB");
jTextField1.setText(named);
jTextField2.setText(mom);
}

    }
    catch(SQLException err)
    {
      JOptionPane.showMessageDialog(Main.this, err.getMessage());
    }
        
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        // TODO add your handling code here:
       String uname= jTextField1.getText();
       String unum=jTextField2.getText();
   


      
       try{
           
           
           
          
       
        rs.moveToInsertRow();
       
                   PreparedStatement preparedStatement = conn.prepareStatement("INSERT INTO coll values (DEFAULT, ?, ?)");
                   
//preparedStatement.setString(1, " ");
preparedStatement.setString(1, uname);
preparedStatement.setString(2, unum);
int rowsInserted=preparedStatement.executeUpdate();
                
           
           
           
           
          
smt.close();
  rs.close();          




smt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);


String query1="SELECT * FROM coll";
rs=smt.executeQuery(query1);
rs.next();


String named=rs.getString("NAME");
String mom=rs.getString("MOB");
jTextField1.setText(named);
jTextField2.setText(mom);

                        }
       catch(SQLException err){
           JOptionPane.showMessageDialog(Main.this, err.getMessage());
       }
       
       
    
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
                  
        
        jTextField1.setText(" ");
        jTextField2.setText(" ");
        
       
       
        
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        
         String uname= jTextField1.getText();
       String unum=jTextField2.getText();
   


      
       try{
           
           
           
       
       rs.updateString("NAME",  uname);
       rs.updateString("MOB", unum);
       rs.updateRow();
       
        JOptionPane.showMessageDialog(Main.this, "udate data");
                                   }
       catch(SQLException err){
           JOptionPane.showMessageDialog(Main.this, err.getMessage());
       }
       
       
    
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
         try{
       rs.deleteRow();
       smt.close();
rs.close();

smt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);


String query1="SELECT * FROM coll";
rs=smt.executeQuery(query1);
rs.next();


String named=rs.getString("NAME");
String mom=rs.getString("MOB");
jTextField1.setText(named);
jTextField2.setText(mom);

                        }
       catch(SQLException err){
           JOptionPane.showMessageDialog(Main.this, err.getMessage());
       }
       
      
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
        // TODO add your handling code here:
    String NN=jTextField3.getText();
         try{
      
     
     String query1="SELECT * FROM coll where NAME='"+NN+"'";
rs=smt.executeQuery(query1);
if(rs.next()){

int idd=rs.getInt("ID");
String named=rs.getString("NAME");
String mom=rs.getString("MOB");
jTextField4.setText(mom);
}
else{
     JOptionPane.showMessageDialog(Main.this, "RECORDNOTFOUND");
}

                        }
       catch(SQLException err){
           JOptionPane.showMessageDialog(Main.this, err.getMessage());
       }
    }//GEN-LAST:event_jButton10ActionPerformed

    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton11ActionPerformed
        // TODO add your handling code here:
         String NN=jTextField4.getText();
         try{
      
     
     String query1="SELECT * FROM coll where MOB='"+NN+"'";
rs=smt.executeQuery(query1);
if(rs.next()){

int idd=rs.getInt("ID");
String named=rs.getString("NAME");
String mom=rs.getString("MOB");
jTextField3.setText(named);
}
else{
     JOptionPane.showMessageDialog(Main.this, "RECORDNOTFOUND");
}

                        }
       catch(SQLException err){
           JOptionPane.showMessageDialog(Main.this, err.getMessage());
       }
   
    }//GEN-LAST:event_jButton11ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    // End of variables declaration//GEN-END:variables
}

===================================================
          

downloads free java programming projects



==========================================================



0 comments:

Post a Comment