JP 6 1 Practice Solution
JP 6 1 Practice Solution
JP 6 1 Practice Solution
Lesson Objectives:
• Describe the JDBC
Vocabulary:
Identify the vocabulary word for each definition below.
Statement The interface used for executing a static SQL statement and returning the results it
produces
Connection The interface which is able to provide information for the tables, stored procedures and so
on.
ORACLE_HOME/jdbc/lib/ojdbc8.jar
ORACLE_HOME/jlib/orai18n.jar
2. Identify the structure of the database tables that you will be working with.
b) Identify the structure of each of the tables by running a DESCRIBE command on the table. Identify column names and data
types.
3. Write a java application to display the information in the JOBS table to the console.
The application should print out the JOB ID, JOB TITLE, MIN SALARY and MAX SALARY columns.
package jobdetails;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;
Statement stmt=conn.createStatement();
// Execute a statement
ResultSet rset= stmt.executeQuery("Select JOB_ID, JOB_TITLE,
MIN_SALARY,MAX_SALARY from jobs");
// Iterate through the result and print the employee names and ID
System.out.println("Job ID" + "\t" +"JOB Title"+"\t"+"Min Salary"+"\t"
+ "Max Salary");
System.out.println();
while (rset.next())
System.out.println(rset.getString(1)
+ "\t" +rset.getString(2)
+ "\t"+rset.getString(3)
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
2
+ "\t"+rset.getString(4));
//endwhile
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.