singleton

Ads
 

singleton

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.*;
import java.util.Scanner;


public class New {

    private static Connection connection = null;  


    public  Connection getConnection()
    {

        try {
            // Load the JDBC driver
            String driverName = "oracle.jdbc.driver.OracleDriver";
            Class.forName(driverName);

            // Create a connection to the database

            String url = "jdbc:oracle:thin:@172.24.137.30:1521:ORA10G" ;
            String username = "e545779";
            String password = "JdyIixugi";
            connection = DriverManager.getConnection(url, username, password);
            System.out.println("hiiiiiiiii");
        } catch (ClassNotFoundException e) {
            // Could not find the database driver
        } catch (SQLException e) {
            // Could not connect to the database
        }


        return connection;


    }   


    private New() {
        super();

    }

    public static  New   empDetails(Connection connection) 
    { 
        try
        {
            String empName;

        int sal,deptId;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter EmpName");
        empName=sc.next();
        System.out.println("Enter sal");
        sal=sc.nextInt();
        System.out.println("Enter deptId");
        deptId=sc.nextInt();

        Statement st=null;

        st=connection.createStatement();
        ResultSet rs1=st.executeQuery("insert into employee values(emp_seq.nextVal, '"+empName+"',"+sal+","+deptId+")");
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }

        return null;
    } 

    public static void main(String[] args) {


        New n=new New();

        int ch;
        System.out.println("Enter ur choice(1.Add details/2.View Details");
        Scanner sc=new Scanner(System.in);
        ch=sc.nextInt();

                switch(ch)
                {

                        case 1:
                                System.out.println("enter emp details");

                                connection=n.getConnection();
                                empDetails(connection);
                                break;

                        case 2:
                                System.out.println("Enter Emp Id:");
                                break;

                        default:
                                System.out.println("no choice");

                }
        }

}
View Answers

Ads









Related Tutorials/Questions & Answers:
singleton class
singleton class  What is singleton class
singleton
Advertisements
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
ModuleNotFoundError: No module named 'singleton'
ModuleNotFoundError: No module named 'singleton'  Hi, My Python... 'singleton' How to remove the ModuleNotFoundError: No module named 'singleton' error? Thanks   Hi, In your python environment you
Java Singleton Pattern
In this section, you will learn about singleton pattern in Java
ModuleNotFoundError: No module named 'celery-singleton'
ModuleNotFoundError: No module named 'celery-singleton'  Hi, My... named 'celery-singleton' How to remove the ModuleNotFoundError: No module named 'celery-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-singleton'
ModuleNotFoundError: No module named 'django-singleton'  Hi, My... named 'django-singleton' How to remove the ModuleNotFoundError: No module named 'django-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'jupyter-singleton'
ModuleNotFoundError: No module named 'jupyter-singleton'  Hi, My... named 'jupyter-singleton' How to remove the ModuleNotFoundError: No module named 'jupyter-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'm-singleton'
ModuleNotFoundError: No module named 'm-singleton'  Hi, My Python... 'm-singleton' How to remove the ModuleNotFoundError: No module named 'm-singleton' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'nocycle-singleton'
ModuleNotFoundError: No module named 'nocycle-singleton'  Hi, My... named 'nocycle-singleton' How to remove the ModuleNotFoundError: No module named 'nocycle-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pmc-singleton'
ModuleNotFoundError: No module named 'pmc-singleton'  Hi, My... 'pmc-singleton' How to remove the ModuleNotFoundError: No module named 'pmc-singleton' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'python-singleton'
ModuleNotFoundError: No module named 'python-singleton'  Hi, My... named 'python-singleton' How to remove the ModuleNotFoundError: No module named 'python-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'python-singleton'
ModuleNotFoundError: No module named 'python-singleton'  Hi, My... named 'python-singleton' How to remove the ModuleNotFoundError: No module named 'python-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'rigger_singleton'
ModuleNotFoundError: No module named 'rigger_singleton'  Hi, My... named 'rigger_singleton' How to remove the ModuleNotFoundError: No module named 'rigger_singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'singleton-admin'
ModuleNotFoundError: No module named 'singleton-admin'  Hi, My... named 'singleton-admin' How to remove the ModuleNotFoundError: No module named 'singleton-admin' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'singleton-decorator'
ModuleNotFoundError: No module named 'singleton-decorator'  Hi, My... named 'singleton-decorator' How to remove the ModuleNotFoundError: No module named 'singleton-decorator' error? Thanks   Hi
ModuleNotFoundError: No module named 'singleton_factory'
ModuleNotFoundError: No module named 'singleton_factory'  Hi, My... named 'singleton_factory' How to remove the ModuleNotFoundError: No module named 'singleton_factory' error? Thanks   Hi, In your
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
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
ModuleNotFoundError: No module named 'django-singleton-admin'
ModuleNotFoundError: No module named 'django-singleton-admin'  Hi...: No module named 'django-singleton-admin' How to remove the ModuleNotFoundError: No module named 'django-singleton-admin' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-singleton-admin-2'
ModuleNotFoundError: No module named 'django-singleton-admin-2'  Hi...: No module named 'django-singleton-admin-2' How to remove the ModuleNotFoundError: No module named 'django-singleton-admin-2' error? Thanks  
ModuleNotFoundError: No module named 'django-singleton-model'
ModuleNotFoundError: No module named 'django-singleton-model'  Hi...: No module named 'django-singleton-model' How to remove the ModuleNotFoundError: No module named 'django-singleton-model' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-admin-app-names-singleton'
ModuleNotFoundError: No module named 'django-admin-app-names-singleton' ...: ModuleNotFoundError: No module named 'django-admin-app-names-singleton' How to remove the ModuleNotFoundError: No module named 'django-admin-app-names-singleton'
Creational Design Patterns
Creational Design Patterns           Singleton Pattern The singleton design... of achieving this pattern. Benefits: Singleton pattern controls access
Design Patterns
Design Patterns  Explain the Factory Pattern, VO Pattern, DAO Pattern, and Singleton Pattern
single ton
single ton  we can call non static method from singleton class
springframework
springframework  singleton class creates only one object throught the jvm is fact?explain how many objects are created in throght jvm

Ads