+ All Categories
Home > Documents > Development of Salary Grades using JDBC

Development of Salary Grades using JDBC

Date post: 07-Apr-2022
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
12
Development of Salary Grades using JDBC By: Dixie Bartholomew
Transcript
Page 1: Development of Salary Grades using JDBC

Development of Salary Grades using JDBC

By: Dixie Bartholomew

Page 2: Development of Salary Grades using JDBC

What is my project?

•  I wrote a Java program which takes an employee’s Id from the user and return the name, job title, salary, and salary grade.

•  The program uses JDBC to connect to the Database.

Page 3: Development of Salary Grades using JDBC

What is JDBC?

•  JDBC(Java Database Connectivity) is a Java API for executing SQL statements.

•  Using JDBC, it is easy to send SQL statements to almost any relational database.

Page 4: Development of Salary Grades using JDBC

Four JDBC Driver Categories

•  JDBC-ODBC bridge plus ODBC driver

•  Native-API partly Java Driver

•  JDBC-Net pure Java Driver

•  Native-protocol pure Java driver

Page 5: Development of Salary Grades using JDBC

ODBC Data Source Administrator

•  Select the appropriate driver.

•  Enter the data source name inside the setup window.

•  Select the directory where the database’s files are stored.

Page 6: Development of Salary Grades using JDBC

Three steps involved in JDBC

•  Establish the connection with the database.

•  Send SQL statements.

•  Process the Results.

Page 7: Development of Salary Grades using JDBC

Establishing the Connection

•  The following is code used to connect to the database

•  Connection con = DriverManager.getConnection

( “jdbc:odbc:abra”, “login”, “password”);

Page 8: Development of Salary Grades using JDBC

The three parts to the URL

•  Protocol

•  subprotocol

•  subname

Page 9: Development of Salary Grades using JDBC

Sending SQL Statements

•  The SQL Statements are:

•  Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery( “SELECT P_EMPNO, P_FNAME, P_LNAME, P_JOBTITLE, P_ANNUAL FROM hrPersnl.dbf”);

•  P_EMPNO P_FNAME P_LNAME 816001 Sally Parker 816002 Billy Smith 816003 Tina Jones

Page 10: Development of Salary Grades using JDBC

Processing the Results

•  I = 0; while ( rs.next ()) {

Id[I] = rs.getInt (“P_EMPNO”); fname[I] = rs.getString(“P_FNAME”); lname[I] = rs.getString(“P_LNAME”); jobtitle[I] = rs.getString(P_JOBTITLE”); salary[I] = rs.getFloat(“P_ANNUAL”); I+

+; }

Page 11: Development of Salary Grades using JDBC

When will this be useful?

•  Promotions •  New Hire Purposes •  Up Grading Positions •  Scheduled Performance Reviews.

Page 12: Development of Salary Grades using JDBC

Problems

•  Registering the Database in the ODBC Data Source Administrator.

•  JDBC Code

•  Syntax


Recommended