Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa WebSevices singleton program

Have Programming Question? Ask it here!
 
 
 


Http Servlet
singleton program
0 Answer(s)      2 years and 3 months ago
Posted in : WebSevices


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();
        }
    }

}

Advertisement
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
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 & 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
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
Java Singleton Pattern
In this section, you will learn about singleton pattern in Java
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
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
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. To get an instance of the singleton pattern we must have
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
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
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
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
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
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
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
program
program  any program of hotel or school management
program
program  write a program different between to dates in terms of days in java
program
program  write a html program in show table and this word in box
program
program  write a javascript program to create a application form with validation
program
program  program of jdbc using ms access for creating table
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
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   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link: Java Threads Thanks
Program
Program  a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
Program
Program  a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = ‚??Tommy‚?? age=‚??23‚?? and call this constructor
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
program
program  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat
program
program  Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program
program  . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program
program  Write a program to print details of a week for a particular day using array of objects Integer and String. OUTPUT: First Day of Week is Monday Second Day of Week is Tuesday Third Day of Week is Wednesday Forth Day
program
program  Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
program
program  Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
Implementing a Serializable Singleton
Implementing a Serializable Singleton   ... and throw ObjectStreamException   Code of the program is given below...;   static SerializableSingleton singleton;  
 

 

 

DMCA.com