singleton program

singleton program

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

import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class Emp{
    public static void main(String[] args) {

        System.out.println("Getting Employee Details Using resultset metadata: ");
        Connection con = null;
        String url = "jdbc:oracle:thin:@172.24.137.30:1521:ORA10G";;

        String driver = "oracle.jdbc.driver.OracleDriver";
        String user = "e206227";
        String pass = "VeuFmodax";
        try{
            Class.forName(driver);
            con = DriverManager.getConnection(url, user, pass);
            try{

                Emp e=new Emp();
                Scanner sc=new Scanner(System.in);   
                int ch=sc.nextInt();
                switch(ch)
                {
                case 1: e.viewDetails(con);
                break;
                case 2: e.addDetails(con);  
                break;
                }


            }
            catch (Exception s){
                System.out.println("SQL statement is not executed!");
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }

    public void viewDetails(Connection con)
    {
        try{
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("SELECT * FROM employee");

            while(rs.next())
            {
                System.out.print("\t"+rs.getString(1));
                System.out.print("\t"+rs.getString(2));
                System.out.print("\t"+rs.getString(3));
                System.out.print("\t"+rs.getString(4));
                System.out.println("\t"+rs.getString(5));
            }

        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public void addDetails(Connection con)
    {
        try
        {
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("insert into employee values('emp005','rakesh',23000,7418767778,'js.rakesh@
xyz.com')");
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

}
View Answers









Related Tutorials/Questions & Answers:
singleton program
singleton program  import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Scanner; public class Emp{ public
Java singleton program - Java Interview Questions
Java singleton program  Hi All, Can you please explain me in brife with an example how the singleton program works, i did see some documents but was not able to unerstand except one object can be used. this was a java
Advertisements
singleton class
singleton class  What is singleton class
Java singleton
Java singleton  What is singleton
ModuleNotFoundError: No module named 'singleton'
ModuleNotFoundError: No module named 'singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'singleton' How to remove the ModuleNotFoundError: No module named '
Singleton in Flex
Singleton in Flex  hi..... please tell me about How can you implement Singleton in Flex Application? please give me the procedure so i can implement....... Thanks
ModuleNotFoundError: No module named 'm-singleton'
ModuleNotFoundError: No module named 'm-singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'm-singleton' How to remove the ModuleNotFoundError: No module named 'm
ModuleNotFoundError: No module named 'nocycle-singleton'
ModuleNotFoundError: No module named 'nocycle-singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'nocycle-singleton' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'pmc-singleton'
ModuleNotFoundError: No module named 'pmc-singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pmc-singleton' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'python-singleton'
ModuleNotFoundError: No module named 'python-singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'python-singleton' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'python-singleton'
ModuleNotFoundError: No module named 'python-singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'python-singleton' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'rigger_singleton'
ModuleNotFoundError: No module named 'rigger_singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'rigger_singleton' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'singleton-admin'
ModuleNotFoundError: No module named 'singleton-admin'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'singleton-admin' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'singleton-decorator'
ModuleNotFoundError: No module named 'singleton-decorator'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'singleton-decorator' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'singleton_factory'
ModuleNotFoundError: No module named 'singleton_factory'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'singleton_factory' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'celery-singleton'
ModuleNotFoundError: No module named 'celery-singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'celery-singleton' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'django-singleton'
ModuleNotFoundError: No module named 'django-singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'django-singleton' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'jupyter-singleton'
ModuleNotFoundError: No module named 'jupyter-singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'jupyter-singleton' How to remove the ModuleNotFoundError: No module
singleton
Singleton & Threadsafe in struts - Struts
Singleton & Threadsafe in struts  Hi, How to implement singleton and threadsafe in struts . same in jsp and servlet. Thanks in advance
singleton pattern - Java Beginners
singleton pattern  how i use singleton pattern in my web aplication project.plz give an example.its urgent
ModuleNotFoundError: No module named 'django-singleton-admin'
ModuleNotFoundError: No module named 'django-singleton-admin'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'django-singleton-admin' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'django-singleton-admin-2'
ModuleNotFoundError: No module named 'django-singleton-admin-2'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'django-singleton-admin-2' How to remove
ModuleNotFoundError: No module named 'django-singleton-model'
ModuleNotFoundError: No module named 'django-singleton-model'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'django-singleton-model' How to remove the ModuleNotFoundError
Java Singleton Pattern
In this section, you will learn about singleton pattern in Java
What is singleton? - Java Beginners
What is singleton?   Hi, I want to know more about the singleton in Java. Please explain me what is singleton in Java? Give me example of Singleton class. Thanks   hello, Singleton is a concept in which you
singleton - Java Interview Questions
singleton  what is singleton class.give one example of implementation of singleton class?  hi friend, import java.io.*; public class SingletonExam implements Serializable { public static SingletonExam single
Is Singleton Default in Struts - Struts
Is Singleton Default in Struts   Hi Friend, Is Singleton default in Struts ,or should we force any technique Thanks Prakash  Hi friend, Use of singletons is normally
PHP Singleton Method
PHP Singleton Method: Many application resources are exclusive like database... to a database is exclusive. The singleton pattern is exactly the same, it uses for creating single object. ADS_TO_REPLACE_1 To get an instance of the singleton pattern
J2EE Singleton Pattern - Design Pattern Tutorials
J2EE Singleton Pattern Singleton Design Pattern This design pattern governs... only one instance of object is required. The Constructor in a Singleton class is private and a public static method is used to get the Object of the Singleton
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
ModuleNotFoundError: No module named 'django-admin-app-names-singleton'
ModuleNotFoundError: No module named 'django-admin-app-names-singleton'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'django-admin-app-names-singleton' How to remove
How singleton in struts - Java Interview Questions
How singleton in struts  Hi, How to implement singleton and threadsafe in struts . same in jsp and servlet. Thanks Prakash
What is difference between singleton and prototype bean?
What is difference between singleton and prototype bean?  Hi, What is difference between singleton and prototype bean? Thanks
What is an efficient way to implement a singleton pattern in Java?
What is an efficient way to implement a singleton pattern in Java?  What is an efficient way to implement a singleton pattern in Java
Singleton class
Singleton class       Singleton Design Pattern: The singleton design pattern allows to have one...:  Singleton pattern provides  -- access only to the unique instances
Why we use singleton class in hibernate sessionfactory?
Why we use singleton class in hibernate sessionfactory?  Hello, Please tell me why we use singleton class in hibernate sessionfactory? hibernate sessionfactory singleton example would be very helpful. Thanks
Singleton Pattern
Singleton Pattern       Singleton Pattern:  The singleton design pattern deals with one... the singleton pattern. But take care to set the variable whenever destroying during
program
program  any program of hotel or school management
program
program  program of jdbc using ms access for creating table
program
program  write a javascript program to create a application form with validation
program
program  write a html program in show table and this word in box
program
program  write a program different between to dates in terms of days in java
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database

Ads