Question

Using Oracle database Need help getting the JAVA code for the queries and the rest of...

Using Oracle database

Need help getting the JAVA code for the queries and the rest of the instructions. Need the table provided converted and fulfil  the requirements.

.

For this project - you will be writing a program (you may choose whatever programming language you want) to read in your database tables from Lab 5, and then print out the contents of each of the tables. Additionally, you must print at least one query each with the following clauses:
*JOIN (any version)
*WHERE
*ORDER BY

You must submit the following:
*Your program's source code
*The SQL commands you used
*Screenshots of the program's output

Lab 5 Table:

Create table Guest
(
GuestId int not null primary key,
GuestFirstName varchar(20),
GuestLastName varchar(20),
GuestAddress varchar(30),
GuestCity varchar (20),
GuestPhone varchar(20),
GuestEmail varchar(30),
StayId int
);

Create table Volunteer
(
VolunteerID int not null primary key,
VolunteerFirstName varchar(30),
VolunteerLastName varchar(20),
VolunteerAddress varchar (30),
VolunteerCity varchar(20),
VolunteerPhone varchar(20),
VolunteerEmail varchar(30),
ShiftID int
);

Create table Shift
(
ShiftID int not null primary key,
ShiftIN Date,
ShiftOut Date
);

Create table Inventory
(
InventorySku int not null primary key,
InventoryName varchar(30),
InventoryPrice dec,
InventoryStocked int
);

Create table Schedule
(
GuestCard int not null primary key,
CheckIn date,
CheckOut date,
room int
);

Create table Donor
(
DonorID int not null primary key,
DonorFirstName Varchar(30),
DonorLastName varchar(20),
DonorAddress varchar(30),
DonorCity varchar (20),
DonorPhone varchar(30),
DonorEmail varchar(30),
DonorAmount int
);

insert into Guest values (1,'Bob','Dylan','607Maine','Greensville','6904931104','[email protected]',635783);
insert into Guest values (2,'Sam','Porter','901Fordza','Drive','79630698836','[email protected]',9924573);
insert into Guest values (3,'Chuck','Barter','Slugaa','Molkvia','3215789033','RoxoN@xxx',63267326);
insert into Guest values (4,'Emma','Stone','411Holly','WoodBlvd','7246793226','CelebInfo@axxxx',1112244778);
insert into Guest values (5,'Paige','Maye','254Looms','Ipelka','35974324780','RoboSwa@xxxx',66447837);

insert into Volunteer values (90,'Mike','Dickeson','32Chicago','Bears','69021356332','MickeyD@xxxx',2019121);
insert into Volunteer values (77,'Coach','Carter','Ludvale','Atlanta','9035467789','CCoach@xxxx',20191090);
insert into Volunteer values (23,'Larry','Ludo','30Mega','Watkinsville','11156267252','RoadHog@xxx',2019315);
insert into Volunteer values (10,'Taylor','Ireka','911Gotham','City','6342139902','TyGod@xxxx',2019923);
insert into Volunteer values (68,'Elvis','Elton','4Rocky Rd','Athens','89513631244','Starway@xxxxxx',20191012);

insert into Shift values (20190207,TO_Date('20190207','YYYYMMDD'),TO_Date('20190213','YYYYMMDD'));
insert into Shift values (20190821,TO_Date('20190821','YYYYMMDD'),TO_Date('20190916','YYYYMMDD'));
insert into Shift values (20190113,TO_Date('20190113','YYYYMMDD'),TO_Date('20190130','YYYYMMDD'));
insert into Shift values (20190420,TO_Date('20190420','YYYYMMDD'),TO_Date('20190501','YYYYMMDD'));
insert into Shift values (20191008,TO_Date('20191008','YYYYMMDD'),TO_Date('20191220','YYYYMMDD'));

Insert into Inventory values (912109,'Clothes',13.43,5);
insert into Inventory values (789567,'Remotes',9.50,3);
insert into Inventory values (605932,'Furniture',26.37,2);
insert into Inventory values (411235,'Sandwhich',3.99,7);
insert into Inventory values (009576,'Bags',0.99,99);

Insert into Schedule values (02072019,TO_Date('20190207','YYYYMMDD'),TO_Date('20190128','YYYYMMDD'),12);
insert into Schedule values (08212019,TO_Date('20190821','YYYYMMDD'),TO_Date('20191108','YYYYMMDD'),14);
insert into Schedule values (01132019,TO_Date('20190113','YYYYMMDD'),TO_Date('20190319','YYYYMMDD'),1);
insert into Schedule values (04202019,TO_Date('20190420','YYYYMMDD'),TO_Date('20190919','YYYYMMDD'),7);
insert into Schedule values (10082019,TO_Date('20191008','YYYYMMDD'),TO_Date('20191028','YYYYMMDD'),6);

Insert into Donor values (003,'Carl','Carly','45Alley','Atlanta',9102108443,'carlCar@xxxxx',76);
insert into Donor values (001,'Chuck','Berry','87Pipernickle','Athens',6782680012,'[email protected]',334);
insert into Donor values (007,'Tom','Jerry','01Which','Watkinsville',6325896541,'[email protected]',600);
insert into Donor values (004,'Todd','Gurley','Football','Stadium',7869367833,'FootB@xxxx',2300);
insert into Donor values (006,'Kanye','West','North','West',6983859205,'Yeezus@xxxx',5000);
insert into Donor values (009,'Kenny','Gee','Worlds','Ends',8374823859,'KenG@xxxxx',34);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

solution: I have used php programming language with html

// ---------------- Connect.php ---------------

<?php
date_default_timezone_set('Asia/Calcutta');

function compressImage($source_url, $destination_url, $quality) {

$info = getimagesize($source_url);

if ($info['mime'] == 'image/jpeg')
$image = imagecreatefromjpeg($source_url);

elseif ($info['mime'] == 'image/gif')
$image = imagecreatefromgif($source_url);

elseif ($info['mime'] == 'image/png')
$image = imagecreatefrompng($source_url);

imagejpeg($image, $destination_url, $quality);
return $destination_url;
}

function base64_to_jpeg($base64_string, $output_file) {
$data = explode( ',', $base64_string );
$data1 = imagejpeg(imagecreatefromstring(base64_decode($data[1])),$output_file,50);
return $output_file;
}

function ago( $time )
{
$time_difference = time() - $time;

if( $time_difference < 1 ) { return 'less than 1 second ago'; }
$condition = array( 12 * 30 * 24 * 60 * 60 => 'year',
30 * 24 * 60 * 60 => 'month',
24 * 60 * 60 => 'day',
60 * 60 => 'hour',
60 => 'minute',
1 => 'second'
);

foreach( $condition as $secs => $str )
{
$d = $time_difference / $secs;

if( $d >= 1 )
{
$t = round( $d );
return '' . $t . ' ' . $str . ( $t > 1 ? 's' : '' ) . ' ago';
}
}
}

function ConvertToK($num) {

if($num>1000) {

$x = round($num);
$x_number_format = number_format($x);
$x_array = explode(',', $x_number_format);
$x_parts = array('k', 'm', 'b', 't');
$x_count_parts = count($x_array) - 1;
$x_display = $x;
$x_display = $x_array[0] . ((int) $x_array[1][0] !== 0 ? '.' . $x_array[1][0] : '');
$x_display .= $x_parts[$x_count_parts - 1];

return $x_display;

}

return $num;
}

function rand_color() {
return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
}


$servername = "localhost";
$uname = "root";
$pword = "";
$dbname = "lab 5";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $uname, $pword);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>

//----------------- END OF CONNECT FILE ------------------------------

//------------------------------- index.php --------------------


<?php
include 'connect.php';


?>

<!DOCTYPE html>
<html>
<head>
<title></title>

<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>


<!-- Display data from volunteer and shift table using join -->

<center>
<h1> Display data from volunteer and shift table using join</h1>
</center>

<table style="width:100%;">
<tr>
<th>Volunteer First Name</th>
<th>Volunteer Last Name</th>
<th>Volunteer Address</th>
<th>Volunteer City</th>
<th>Volunteer Phone</th>
<th>Volunteer Email</th>
<th>Shift IN </th>
<th>Shift Out </th>
</tr>
  

<?php

$stmt = $conn->prepare("SELECT v.VolunteerFirstName as vfn, v.VolunteerLastName as vln, v.VolunteerAddress as va, v.VolunteerCity as vc, v.VolunteerPhone as vp, v.VolunteerEmail as ve, s.ShiftIN as sin, s.ShiftOut as sout from volunteer as v join shift as s on s.ShiftID=v.ShiftID ");
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
if($stmt->rowCount()>0){
foreach(($stmt->fetchAll()) as $k=>$row) {
echo '<tr>';
echo '<td>' .$row['vfn']. '</td>';
echo '<td>' .$row['vln']. '</td>';

echo '<td>' .$row['va']. '</td>';
echo '<td>' .$row['vc']. '</td>';

echo '<td>' .$row['vp']. '</td>';
echo '<td>' .$row['ve']. '</td>';
echo '<td>' .$row['sin']. '</td>';
echo '<td>' .$row['sout']. '</td>';

echo ' </tr>';

}
}

?>

</table>


<br><br><br>

<!-- Display guest using where clause -->
<center>
<h1>Display guest using where clause</h1>
</center>
<table style="width:100%;">
<tr>
<th>Guest First Name</th>
<th>Guest Last Name</th>
<th>Guest Address</th>
<th>Guest City</th>
<th>Guest Phone</th>
<th>Guest Email</th>

</tr>
  

<?php

$stmt = $conn->prepare("SELECT * from guest where GuestId=1 ");
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
if($stmt->rowCount()>0){
foreach(($stmt->fetchAll()) as $k=>$row) {
echo '<tr>';
echo '<td>' .$row['GuestFirstName']. '</td>';
echo '<td>' .$row['GuestLastName']. '</td>';

echo '<td>' .$row['GuestAddress']. '</td>';
echo '<td>' .$row['GuestCity']. '</td>';

echo '<td>' .$row['GuestPhone']. '</td>';
echo '<td>' .$row['GuestEmail']. '</td>';


echo ' </tr>';

}
}

?>

</table>

<br><br><br>

<!-- Display guest using order by clause -->
<center>
<h1>Display guest using order by clause</h1>
</center>

<table style="width:100%;">
<tr>
<th>Guest Id's</th>
<th>Guest First Name</th>
<th>Guest Last Name</th>
<th>Guest Address</th>
<th>Guest City</th>
<th>Guest Phone</th>
<th>Guest Email</th>

</tr>
  

<?php

$stmt = $conn->prepare("SELECT * from guest ORDER BY GuestId desc ");
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
if($stmt->rowCount()>0){
foreach(($stmt->fetchAll()) as $k=>$row) {
echo '<tr>';
echo '<td>' .$row['GuestId']. '</td>';

echo '<td>' .$row['GuestFirstName']. '</td>';
echo '<td>' .$row['GuestLastName']. '</td>';

echo '<td>' .$row['GuestAddress']. '</td>';
echo '<td>' .$row['GuestCity']. '</td>';

echo '<td>' .$row['GuestPhone']. '</td>';
echo '<td>' .$row['GuestEmail']. '</td>';


echo ' </tr>';

}
}

?>

</table>

</body>
</html>

//------------------------ end of index.php file -------------------

Add a comment
Know the answer?
Add Answer to:
Using Oracle database Need help getting the JAVA code for the queries and the rest of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using the code below in Oracle SQL Live I keep getting an error message for the...

    Using the code below in Oracle SQL Live I keep getting an error message for the last 4 INSERTS. The error message is: ORA-00932: inconsistent datatypes: expected DATE got NUMBER. How do I correct that error? CREATE TABLE BASE ( BASENUM CHARACTER(3) NOT NULL, BASECITY varchar(20), BASESTATE CHARACTER(2), BASEPHON varchar(10), BASEMGR varchar(10), PRIMARY KEY (BASENUM) ); CREATE TABLE TYPE ( TYPENUM CHARACTER(1) NOT NULL, TYPEDESC varchar(30), PRIMARY KEY (TYPENUM) ); CREATE TABLE TRUCK ( TNUM CHARACTER(4) NOT NULL, BASENUM CHARACTER(3),...

  • I am using oracle sql developer to create some queries to generated reports and it is...

    I am using oracle sql developer to create some queries to generated reports and it is not working. I am not sure how to use count, group by, and order by. Help me fix my query and explain to me how you did, so can do it next time. Also, I have to convert this query to a stored procedure, so can you help me do it too? Here is my query: SELECT COUNT(GUEST.FIRSTNAME), GUEST.FIRSTNAME, GUEST.LASTNAME, GUEST.GUESTTYPE, RESERVATION.RESERVATIONDATE, GUEST.EMAIL, FROM...

  • Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and...

    Database HW help!!!!!!! Provide the SQL statements for the following queries. (1) Provide the names and phones of all swimmers currently in level (of id) 3. +-------+---------+---------------------------+ | FName | LName   | EMail                     | +-------+---------+---------------------------+ | Bobby | Khan    | theBKhan1 | | Clara | Johnson | ClaraJohnson_11 | +-------+---------+---------------------------+ 2 rows in set (0.00 sec) (2) Provide the names of swimmers who have signed up to participate in the event '100M Butterfly' of Meet id 1. +-------+---------+ | FName...

  • I need help with the following SQL query for a company database (script given below). The...

    I need help with the following SQL query for a company database (script given below). The name of the Department. The number of employees working in that department. The number of different projects controlled by this department. The name of the project controlled by this department that has the maximum number of employees of the company working on it. The number of the above project. The cumulative sum of the number of employees of the company working on the projects...

  • Help In Database: Next comes the data entry: Make up data for your database, or find...

    Help In Database: Next comes the data entry: Make up data for your database, or find real data. You can enter the data with INSERT statements, but it is much easier to use PhpAdmin. It has a form where you can type the data directly. Alternatively, you can use PhpAdmin to import CSV data (comma-separated values), which you can export from Excel. Include at least 3 rows in each of the entity relations, and as many rows as you need...

  • Query #2:       List the name of the project and total number of hours worked on by...

    Query #2:       List the name of the project and total number of hours worked on by all the employees on this project, also report the number of employees working on each project. Database: //STEP #1: CREATE TABLE employee ( fname varchar(15) not null, minit varchar(1), lname varchar(15) not null, ssn char(9), bdate date, address varchar(50), sex char, salary decimal(10,2), Super_ssn char(9), dno char(4), primary key (ssn)); CREATE TABLE department ( dname varchar(25) not null, dnumber char(4), Mgr_ssn char(9) not null,...

  • Query 1: Retrieve names of all the projects as well as First and Last name of...

    Query 1: Retrieve names of all the projects as well as First and Last name of managers if they are working on any of these projects. Database: //STEP #1: CREATE TABLE employee ( fname varchar(15) not null, minit varchar(1), lname varchar(15) not null, ssn char(9), bdate date, address varchar(50), sex char, salary decimal(10,2), Super_ssn char(9), dno char(4), primary key (ssn)); CREATE TABLE department ( dname varchar(25) not null, dnumber char(4), Mgr_ssn char(9) not null, Mgr_start_date date, primary key (dnumber)); CREATE...

  • /* I am executing following SQL statement for the below code but I am getting error....

    /* I am executing following SQL statement for the below code but I am getting error. Pls, upload screenshot after running it. SQL Statement: SELECT OfferNo, CourseNo FROM Offering WHERE OfferTerm = 'Sum' AND OfferYear = 2012 AND FacSSN IS NULL; */ CREATE TABLE STUDENT( StdSSN INT NOT NULL PRIMARY KEY, StdFName VARCHAR2(50), StdLName VARCHAR2(50), StdCity VARCHAR2(50), StdState VARCHAR2(2), StdZip VARCHAR2(10), StdMajor VARCHAR2(15), StdYear VARCHAR2(20) ); CREATE TABLE FACULTY( FacSSN INTEGER NOT NULL PRIMARY KEY, FacFName VARCHAR(50), FacLName VARCHAR(50), FacCity...

  • Oracle only database: DROP TABLE ORDERITEMS; DROP TABLE Orders; DROP TABLE BOOKAUTHOR; DRO...

    oracle only database: DROP TABLE ORDERITEMS; DROP TABLE Orders; DROP TABLE BOOKAUTHOR; DROP TABLE BOOKS; DROP TABLE PROMOTION; DROP TABLE AUTHOR; DROP TABLE CUSTOMERS; DROP TABLE PUBLISHER; CREATE TABLE Customers ( Customer# NUMBER(4), LastName VARCHAR2(10) NOT NULL, FirstName VARCHAR2(10) NOT NULL, Email VARCHAR(40), Address VARCHAR2(20), City VARCHAR2(12), State VARCHAR2(2), Zip VARCHAR2(5), Referred NUMBER(4), Region CHAR(2), CONSTRAINT customers_customer#_pk PRIMARY KEY(customer#) ); INSERT INTO CUSTOMERS VALUES (1001, 'MORALES', 'BONITA', '[email protected]', 'P.O. BOX 651', 'EASTPOINT', 'FL', '32328', NULL, 'SE'); INSERT INTO CUSTOMERS VALUES...

  • Database Management 6. [5] Create the following table: CREATE TABLE customer ( cust_name VARCHAR(30) NOT NULL,...

    Database Management 6. [5] Create the following table: CREATE TABLE customer ( cust_name VARCHAR(30) NOT NULL, address VARCHAR(60), UNIQUE (cust name, address)); A. Run the following inserts and explain why both work and how will you prevent it INSERT INTO customer VALUES ('Alex Doe', NULL); INSERT INTO customer VALUES ('Alex Doe', NULL); 7. [5] Modify the following table definition to ensure that all employees have a minimum wage of $10 CREATE TABLE employee ( empId INT PRIMARY KEY, empName VARCHAR(40)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT