/*
 * This sample shows how to list all the names from the EMP table
 */

// You need to import the java.sql package to use JDBC
import java.sql.*;

class Employee
{
 public static void main (String args [])
 {
  try {
    // Load the Oracle JDBC driver
    try {
      Class.forName("oracle.jdbc.driver.OracleDriver");
    } catch (ClassNotFoundException e) {
      System.out.println ("Oracle device driver does not exist");
      System.exit(1);
    }

    // Connect to the database
    // You can put a database name after the @ sign in the connection URL.
    Connection conn =
    DriverManager.getConnection ("jdbc:oracle:thin:@oradev:10521:D", "rramos", "raul");

    // Create a Statement
    Statement stmt = conn.createStatement ();

    // Select the ENAME column from the EMP table
    ResultSet rset = stmt.executeQuery ("selects ENAME, JOB, SAL, HIREDATE from EMP");

    // Iterate through the result and print the employee names
    while (rset.next ())  {
      System.out.print   ("Name "+rset.getString (1));
      System.out.print   (" Job "+rset.getString(2));
      System.out.print   (" Salary "+ rset.getString(3));
      System.out.println (" HDate "+ rset.getString(4));
    }
     

    // Close the RseultSet
    rset.close();

    // Close the Statement
    stmt.close();

    // Close the connection
    conn.close();   
   } catch (SQLException e) {
      System.out.println("Error accessing DB ");
      System.out.println("  Error code is : "+e.getErrorCode());
      System.out.println("  Error message is :"+e.getMessage());
   }
  }
}
