how to apply  select query in java how to apply  select query in java with server ,how to apply  select query in java with sql

 How to apply  select query in java 
How to apply  select query in java with server
How to apply  select query in java with sql







package exam;

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;

    import javax.swing.JOptionPane;

    public class SelectClass {
       
        public static void main(String[] args) {
       
        String  url   =   "jdbc:mysql://localhost:3306/pharmacy" ;
        String  name = "root";
        String  password = "admin";
       
       
        Connection  conn =  null ;
        Statement stm  =  null ;
        ResultSet result  =  null ;
        java.sql.PreparedStatement pst ;
        try{
           
            conn=DriverManager.getConnection(url,name,password);
            stm=conn.createStatement();   

// Select Query
            String query=  "Select * from  pharmacy.customer  where Id=5  " ;

            pst = conn.prepareStatement(query) ;
            result=pst.executeQuery();           
            System.out.println("" +result);
        }
        catch(SQLException e) {
            e.getStackTrace();
            JOptionPane.showMessageDialog(null,"U are  not Connected With Server ");
            }
        }
    }
   

Reviews:

Post a Comment

OwnMaterial © 2014 - Designed by Templateism.com, Plugins By MyBloggerLab.com Published By Kaizen Template - Support KaizenThemes

Contact us

Powered by Blogger.