singleton

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









Related Tutorials/Questions & Answers:
singleton class
singleton class  What is singleton class
Java singleton
Java singleton  What is singleton
Advertisements
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
singleton
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 & 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 '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
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
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 '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 '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 '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 '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 '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
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
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
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
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
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
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-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-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  
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
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
where singleton class used in java - Java Interview Questions
where singleton class used in java  where singleton classes are used in j2ee web application.can we use it for connection pooling. Thanks Prakash
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'
org.wildfly - wildfly-clustering-singleton-api version 11.0.0.CR1 Maven dependency. How to use wildfly-clustering-singleton-api version 11.0.0.CR1 in pom.xml?
org.wildfly  - Version 11.0.0.CR1 of wildfly-clustering-singleton-api... of wildfly-clustering-singleton-api in pom.xml? How to use wildfly-clustering-singleton...-clustering-singleton-api in project by the help of adding the dependency
org.wildfly - wildfly-clustering-singleton-api version 14.0.1.Final Maven dependency. How to use wildfly-clustering-singleton-api version 14.0.1.Final in pom.xml?
org.wildfly  - Version 14.0.1.Final of wildfly-clustering-singleton-api... of wildfly-clustering-singleton-api in pom.xml? How to use wildfly-clustering-singleton-api version 14.0.1.Final in pom.xml? Learn to use this dependency in your
Maven Repository/Dependency: org.wildfly | wildfly-clustering-singleton-api
Maven Repository/Dependency of Group ID org.wildfly and Artifact ID wildfly-clustering-singleton-api. Latest version of org.wildfly:wildfly-clustering-singleton-api dependencies. # Version Release Date
Maven dependency for org.wildfly - wildfly-clustering-singleton-api version 27.0.0.Final is released. Learn to use wildfly-clustering-singleton-api version 27.0.0.Final in Maven based Java projects
-clustering-singleton-api released The developers of   org.wildfly - wildfly-clustering-singleton-api project have released the latest version...-clustering-singleton-api library is 27.0.0.Final. Developer can use
Maven dependency for org.wildfly - wildfly-clustering-singleton-api version 27.0.1.Final is released. Learn to use wildfly-clustering-singleton-api version 27.0.1.Final in Maven based Java projects
-clustering-singleton-api released The developers of   org.wildfly - wildfly-clustering-singleton-api project have released the latest version...-clustering-singleton-api library is 27.0.1.Final. Developer can use
Maven dependency for org.wildfly - wildfly-clustering-singleton-api version 27.0.0.Alpha4 is released. Learn to use wildfly-clustering-singleton-api version 27.0.0.Alpha4 in Maven based Java projects
of wildfly-clustering-singleton-api released The developers of   org.wildfly - wildfly-clustering-singleton-api project have released the latest version...-clustering-singleton-api library is 27.0.0.Alpha4. Developer can use
Maven dependency for org.wildfly - wildfly-clustering-singleton-api version 27.0.0.Beta1 is released. Learn to use wildfly-clustering-singleton-api version 27.0.0.Beta1 in Maven based Java projects
-clustering-singleton-api released The developers of   org.wildfly - wildfly-clustering-singleton-api project have released the latest version...-clustering-singleton-api library is 27.0.0.Beta1. Developer can use
Maven dependency for org.wildfly - wildfly-clustering-singleton-api version 27.0.0.Alpha5 is released. Learn to use wildfly-clustering-singleton-api version 27.0.0.Alpha5 in Maven based Java projects
of wildfly-clustering-singleton-api released The developers of   org.wildfly - wildfly-clustering-singleton-api project have released the latest version...-clustering-singleton-api library is 27.0.0.Alpha5. Developer can use

Ads