singleton program

Ads
 

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,'[email protected]
xyz.com')");
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

}
View Answers

Ads









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
singleton class
singleton class  What is singleton class
Advertisements
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 '
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
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
singleton
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-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
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
Java Singleton Pattern
In this section, you will learn about singleton pattern in Java
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
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
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... be achieved in java by making a Singleton  class Benefits:  Singleton
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  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  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi

Ads