Friday, June 15, 2018

Employee's Contact List System in Java JDBC and Oracle Database

Hi there in this article I would like to share with you a sample program that I wrote using Java JDBC and Oracle database to manage the contacts of the employees in the company. I called this program Employee's Contact List System in Java JDBC and Oracle Database. It demonstrates the concept of all basic database operations CRUD (Create, Retrieve, Update and Delete). It allows the user to add, update, delete, view all the records and single employee's record and quite the program. I hope you will find my work useful.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.






Sample Program Output

Program Listing

CRUD.java


package oraclecon;

/**
 *
 * @author Mr. Jake R. Pomperada, MAED-IT
 * Date : June 14, 2018  Thursday
 * Home Address: #25-31 Victoria Malaga Street, Eroreco Subdivision, 
 *               Barangay Mandalagan, 6100 Bacolod City, Negros Occidental
 * Email Address : jakerpomperada@yahoo.com and jakerpomperada@gmail.com
 */
import java.sql.*;
import java.io.*;

public class CRUD {

    Connection con;
    PreparedStatement ps;

    public CRUD() {
        try {
             Class.forName("oracle.jdbc.driver.OracleDriver");
             con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "hr");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
                
    
    public void insertEmp(int id, String lastname, String firstname, String address, String email, String mobile) {
        try {
            ps = con.prepareStatement("INSERT INTO HR.EMP values(?,?,?,?,?,?)");
            ps.setInt(1, id);
            ps.setString(2, lastname);
            ps.setString(3, firstname);
            ps.setString(4, address);
            ps.setString(5, email);
            ps.setString(6, mobile);
            int i = ps.executeUpdate();
            if (i != 0) {
                System.out.println("Record is successfully inserted in the database.");
                System.out.println();
            } else {
                System.out.println("Record is not successfully inserted in the database.");
                System.out.println();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateEmp(int id, String lastname, String firstname, String address, String email, String mobile) {
        try {
            ps = con.prepareStatement("UPDATE HR.EMP SET lastname=?,firstname=?,address=?,email=?,mobile=? WHERE id=?");
            ps.setString(1, lastname);
            ps.setString(2, firstname);
            ps.setString(3, address);
            ps.setString(4, email);
            ps.setString(5, mobile);
            ps.setInt(6, id);
            int i = ps.executeUpdate();
            if (i != 0) {
                System.out.println("Record is succesffuly updated.");
                System.out.println();
            } else {
                System.out.println("Record is not updated.");
                System.out.println();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteEmp(int id) {
        try {
            ps = con.prepareStatement("DELETE FROM HR.emp WHERE id=?");
            ps.setInt(1, id);
            int i = ps.executeUpdate();
            if (i != 0) {
                System.out.println("Record is succesfully deleted.");
                System.out.println();
            } else {
                System.out.println("Record is not deleted.");
                System.out.println();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void dispAll() {
        try {
            Statement st = con.createStatement();
            ResultSet res = st.executeQuery("SELECT * FROM HR.EMP");
            while (res.next()) {
                System.out.println("ID Number       : " + res.getString(1));
                System.out.println("Last Name       :  " + res.getString(2));
                System.out.println("First Name      :   " + res.getString(3));
                System.out.println("Home Address    : " + res.getString(4));
                System.out.println("Email Address   : " + res.getString(5));
                System.out.println("Mobile Number   :  " + res.getString(6));
                System.out.println();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void dispAnEmp(int s) {
        try {
            ps = con.prepareStatement("SELECT * FROM HR.EMP WHERE id=?");
            ps.setInt(1, s);
            ResultSet res = ps.executeQuery();
            if (res.next()) {
                System.out.println("ID Number       : " + res.getString(1));
                System.out.println("Last Name       :  " + res.getString(2));
                System.out.println("First Name      :   " + res.getString(3));
                System.out.println("Home Address    : " + res.getString(4));
                System.out.println("Email Address   : " + res.getString(5));
                System.out.println("Mobile Number   :  " + res.getString(6));
                System.out.println();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        try {
            CRUD obj = new CRUD();
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int ch = 0;
            while (true) {
                System.out.println("\tEMPLOYEE'S CONTACT LIST SYSTEM IN JAVA JDBC AND ORACLE DATABASE\n\n"
                        + "\t\t CREATED BY MR. JAKE RODRIGUEZ POMPERADA,MAED-IT \n\n"
                        + "\t 1. ADD EMPLOYEE'S RECORD \n "
                        + "\t 2. UPDATE EMPLOYEE'S RECORD \n "
                        + "\t 3. DELETE EMPLOYEE'S RECORD \n "
                        + "\t 4. DISPLAY ALL EMPLOYEE'S RECORD \n "
                        + "\t 5. DISPLAY A SINGLE EMPLOYEE'S RECORD \n"
                        + "\t 6. QUIT PROGRAM \n\n"
                        + "\t SELECT YOUR OPTION :  \n");
                String str1 = br.readLine().toString();
                ch = Integer.parseInt(str1);
                switch (ch) {
                    case 1: {
                        System.out.println("Employee Code ");
                        String code = br.readLine();
                        int id = Integer.parseInt(code);
                        System.out.println("Last Name" );
                        String lastname = br.readLine();
                        System.out.println("First Name ");
                        String firstname = br.readLine();
                        System.out.println("Address ");
                        String address = br.readLine();
                        System.out.println("Email ");
                        String email = br.readLine();
                        System.out.println("Mobile ");
                        String mobile = br.readLine();
                        obj.insertEmp(id,lastname,firstname,address,email,mobile);
                        break;
                    }
                    case 2: {
                        System.out.println("Employee Code ");
                        String code = br.readLine();
                        int id = Integer.parseInt(code);
                        System.out.println("Last Name" );
                        String lastname = br.readLine();
                        System.out.println("First Name ");
                        String firstname = br.readLine();
                        System.out.println("Address ");
                        String address = br.readLine();
                        System.out.println("Email ");
                        String email = br.readLine();
                        System.out.println("Mobile ");
                        String mobile = br.readLine();
                        obj.updateEmp(id,lastname,firstname,address,email,mobile);
                        break;
                    }
                    case 3: {
                        System.out.print("Enter Employee Code to delete record : ");
                        String code = br.readLine();
                         int id = Integer.parseInt(code);
                        obj.deleteEmp(id);
                        break;
                    }
                    case 4: {
                        obj.dispAll();
                        break;
                    }
                    case 5: {
                        System.out.print("Enter Employee Code to display record : ");
                        String code = br.readLine();
                        int id = Integer.parseInt(code);
                        obj.dispAnEmp(id);
                        break;
                    }
                    case 6:
                    {
                        System.exit(0);
                    }
                    default:
                        break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}  // End of Code







Sunday, June 10, 2018

Insert Record in Java JDBC and Oracle 11g Database

In this article I would like to share with you how to insert or add a record using Java JDBC and Oracle 11g database express edition that code is very simple and easy to understand.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.








Sample Program Output

Program Listing

InsertRecord.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package oraclecon;

import java.sql.*;

/**
 *
 * @author Jake Pomperada
 */
public class InsertRecord {
    public static void main(String args[])
    {
        int Id = 6;
        String Name = "JULIANNA";
        int Age=4;
        String Address ="BACOLOD";
         
        try
        {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "hr");
            Statement stmt = con.createStatement();
             
            // Inserting data in database
            String q1 = "INSERT INTO hr.customers VALUES('" +Id+ "', '" +Name+ 
                                  "', '" +Age+ "', '" +Address+ "')";
            int x = stmt.executeUpdate(q1);
            if (x > 0)            
                System.out.println("Successfully Inserted");            
            else           
                System.out.println("Insert Failed");
             
            con.close();
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}


Customer Listing System Using Java JDBC and Oracle Database

In this article I would like to share with you guys a program that I wrote using Java JDBC and Oracle 11g Express Edition to display the customer records from the Oracle Database. This will be my first time to use Oracle as my database to store records of the customer. I find it very challenging at first but it is very worth while in learning new database like Oracle. I hope you find it useful my sample program.  

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.







Sample Program Output

Program Listing

Oraclecon.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


package oraclecon;


import java.sql.*;  
import java.sql.DriverManager;
import java.sql.Connection;

/**
 *
 * @author Jake R. Pomperada
 * June 10, 2018
 * Sunday, Bacolod City, Negros Occidental
 */
public class OracleCon {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       try{  
//step1 load the driver class  
Class.forName("oracle.jdbc.driver.OracleDriver");  
  
//step2 create  the connection object  
Connection con=DriverManager.getConnection(  
"jdbc:oracle:thin:@localhost:1521:xe","system","hr");  
  
//step3 create the statement object  
Statement stmt=con.createStatement();  
  
//step4 execute query  

System.out.println("CUSTOMER LISTING SYSTEM USING JAVA JDBC AND ORACLE DATABASE");
System.out.println();
System.out.println("Created By Mr. Jake R. Pomperada,MAED-IT");
System.out.println();

ResultSet rs=stmt.executeQuery("SELECT * FROM HR.CUSTOMERS ORDER BY ID ASC ");  
while(rs.next())  {
System.out.println("ID       :    "  +  rs.getInt(1));
System.out.println("Name     :    "  +  rs.getString(2));
System.out.println("Age      :    "  +  rs.getString(3));
System.out.println("Address  :    "  +  rs.getString(4));  
System.out.println(); 

  
}
System.out.println();
System.out.println("===== End of Program =====");
System.out.println(); 
//step5 close the connection object 
con.close();
}catch(Exception e){ System.out.println(e);}  
  
    }
    
}




Thursday, June 7, 2018

Color Checker in Turbo Pascal

In this article I would like to share with you a sample program that will use case conditional statement in Turbo Pascal. What the program does is to ask the user to give a letter and then our program will check and determine what is the corresponding color will be display on the screen based on the letter being given by our user. I am using Turbo Pascal for Windows in writing this simple program of ours.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.







Sample Program Output


Program Listing

color.pas

(* color.pas                                                        *)
(* Author : Mr. Jake R. Pomperada, MAED-IT                          *)
(* June 7, 2018 Thursday                                            *)
(* Eroreco Subdivision, Bacolod City, Negros Occidental Philippines *)

program ColorChecker;

uses
  WinCrt;


Var Select_Color : Char;

Begin
  Write('Color Checker in Turbo Pascal');
  Writeln;
  Write('Written By Mr. Jake R. Pomperada, MAED-IT');
  Writeln;
  Writeln;
  Write('Give a Letter : ');
  Readln(Select_Color);
  Writeln;
  Writeln;
  Case Select_Color of
     'B','b' : writeln('You have selected BLUE Color');
     'R','r' : writeln('You have selected RED Color');
     'G','g' : writeln('You have selected GREEN Color');
     'V','v' : writeln('You have selected VIOLET Color');
 Else
    Writeln('Sorry unknown color selected.');
 end;
 Writeln;
 Write('End of Program');
 Writeln;
End.

Monday, June 4, 2018

While Loop Statement in PHP

A very simple program that I wrote in PHP to demonstrate the use of while loop statement.

I am currently accepting programming work, it project, school 

programming projects , thesis and capstone projects, IT consulting 

work and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.



Sample Program Output


Program Listing

while.php

<?php 
$x = 1; 


echo "<h1> While Statement in PHP </h1>";
echo "<br>";

while($x <= 10) {
    echo "The number is: $x <br>";
    $x++;
?>