Skip to main content

Connect to Oracle : A java servlet program

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class connToHr extends HttpServlet
{
    public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
    {
           
            PrintWriter out=res.getWriter();
        try
        {
            String conURL="jdbc:oracle:thin:@localhost:1521:orcl";
            String conUSER="HR";
            String conPASSWORD="HR";   
            String uniDriver="sun.jdbc.odbc.JdbcOdbcDriver";
            Driver d=(Driver)Class.forName(uniDriver).newInstance();   
            Connection con=DriverManager.getConnection(conURL,conUSER,conPASSWORD);
            Statement stmt=con.createStatement();
            ResultSet rs;    
             rs= stmt.executeQuery("SELECT * FROM EMPLOYEES");
   

            while(rs.next())
            {
                out.println("<HTML><BODY><H1>THE EMPLOYEE DETAILS ARE</H1><TABLE>");
                out.println("<TR><TD>"+rs.getString("EMPLOYEE_ID")+"</TD><TD>"+
                    rs.getString("FIRST_NAME")+"</TD><TD>"+rs.getString("SALARY")+"</TD></TR>");
                out.println("</TABLE>");
            }
        }catch(Exception e){out.println(e.getMessage());}
    }
}
       

Comments

Popular posts from this blog

A Hit Count Using Java Servlet's Session Tracking

import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class SessionTracker extends HttpServlet {         public void doGet(HttpServletRequest req,HttpServletResponse res)         throws ServletException,IOException         {                res.setContentType("text/html");                PrintWriter out=res.getWriter();                HttpSession session=req.getSession(true);                Integer count=(Integer)session.getValue("tracker.count");                if(count==null)       ...

Java Sample: While loop

public class whilechk1 {     public static void main(String args[])     {         int row,column,y;         System.out.print("\nMultiplication Table\n");         row=1;         do         {             column=1;             do             {                 y=row*column;                 System.out.print("\t"+y);                 column++;             }while(column<=10);             System.out.println("\n");             row++;         }while(row<=10);     } }

Types of Backups in RMAN

RMAN is very flexible and it offers many different types of backups.  We need to start with a list of backup types: ·           Full backup:   A full backup backs up all data files in the database, block-by-block, a standalone backup with everything you need to recover to the point in time when the full backup was collected. ·           Level 1 backup:   A level 1 backup includes only those blocks that have been changed since the “parent” backup was taken. Remember a parent backup may be either a level 0 or a level 1 backup. ·           Level 0 backup:   A level 0 incremental backup is physically identical to a full backup and it includes every data block in the file except empty blocks. The only difference is that the level 0 backup is recorded as an incremental backup in the RMAN repository, so it can be used as the parent f...