0% found this document useful (0 votes)
8 views2 pages

Tutorial

This document provides instructions for a Distributed Computing Lab tutorial for MSc Cyber Security students at PSG College of Technology. It outlines steps to connect to an Oracle database, create a table, and develop a Java program to query employee data. The tutorial includes a sample Java code for retrieving and displaying employee information from the database.

Uploaded by

wimel85164
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Tutorial

This document provides instructions for a Distributed Computing Lab tutorial for MSc Cyber Security students at PSG College of Technology. It outlines steps to connect to an Oracle database, create a table, and develop a Java program to query employee data. The tutorial includes a sample Java code for retrieving and displaying employee information from the database.

Uploaded by

wimel85164
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PSG COLLEGE OF TECHNOLOGY, COIMBATORE - 641 004

Department of Applied Mathematics and Computational Sciences


MSc CYBER SECURITY – Semester VI
20XC68 DISTRIBUTED COMPUTING LAB
JAVA & Oracle Tutorial

Instructions to follow:

1. Open Oracle SQL Developer tool


2. Click File -> New -> Database Connection
3. Type Name (for your reference), provided Username, Password, Hostname, Port and
Service name and click Connect.
4. Right Click -> Database and create Table, insert fields with Column Name, Data Type,
Constraint etc.
5. Save your work.

6. Open any IDE tool to develop a java program to query the table created in the database.
7. The JAVA program is as follows:
import java.sql.DriverManager;
import java.sql.Connection;
import java.lang.Exception;
import java.sql.Statement;
import java.sql.ResultSet;
public class SelectEmployeeData {
public static void main(String args[]){
Connection con = null;
Statement statement = null;
String sql;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con =
DriverManager.getConnection("jdbc:oracle:thin:@10.1.67.153:1522:orclNew",
"username","password");
statement = con.createStatement();
sql = "Select * from Employee";
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
System.out.println("\nEmployee ID: "+resultSet.getString(1));
System.out.println("Employee Name: "+resultSet.getString(2));
System.out.println("Designation: "+resultSet.getString(3));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
8. Add the library called ojdbc8.jar in the created JAVA project.
9. Compile the JAVA file
10. Execute the JAVA file and verify the output.

You might also like