0% found this document useful (0 votes)
6 views30 pages

IV Reportfinal1

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)
6 views30 pages

IV Reportfinal1

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/ 30

MVGM GOVERNMENT POLYTECHNIC

COLLEGE,VENNIKULAM

INDUSTRIAL TRAINING REPORT

Submitted by
NANDHU RAJ
S5 COMPUTER ENGINEERING
REGISTER NO: 19130964

DEPARTMENT OF COMPUTER ENGINEERING


2019-2022
MVGM GOVERNMENT POLYTECHNIC

COLLEGE,VENNIKULAM

CERTIFICATE

Certified that this Industrial Training report is the bonafied work of NANDHU
RAJ (REG NO: 19130964) who carried out the work at SPECTRUM SOFTTECH
SOLUTIONS PVT.LTD MAHAKAVI G ROAD, KOCHI.

Mrs. BEENA L S Mrs. ASHA SUKUMARAN


(HEAD OF SECTION) (C0-ORDINATOR)

INTERNAL EXAMINER EXTERNAL EXAMINER

PLACE: VENNIKULAM EXAMINERS


DATE: 1.
2.
ACKNOWLEDGEMENT

The completion of this work could have been possible with continued and dedicated
efforts and guidance of large number of faculty and staff members of the institute. I
acknowledge my gratitude to all of them.

The acknowledgement however will be incomplete without specific mentions as follows:

Our Principal Mr. Biju George for giving me an opportunity to go for an Industrial Visit.

Our HOD Mrs. BEENA L S for her technical support, guidance and co-operation for the
successful completion of this study.

Our tutor Mrs. Asha Sukumaran for her mental support and guidance. I would like to
say that I am indebted to my parents, my friends and well-wishers for everything that they
have done for me. All of this would have been impossible without their constant support.
And I also thank God being kind to me and driving me through this journey.

I am very much thankful to my parents who guided me in every step I took.

Last but not the least I would like to express my sincere thanks to every one and apologies
to any one who deserve name fails to appear in the list above.

NANDHU RAJ
INDEX

1.INTRODUCTION.........................................................................................1
1.1 WHAT IS CRUD...............................................................................1
1.2 WHAT IS JDBC................................................................................1
1.3 FUNDATMENTAL STEPS IN JDBC..............................................1
1.4 JDBC API...........................................................................................2
2.DAILY REPORT...........................................................................................3
2.1 FIRST DAY.......................................................................................3
2.2 SECOND DAY..................................................................................6
2.2.1 SOURCE CODE....................................................................7
2.2.2 OUTPUT..............................................................................21
2.3 THIRD DAY....................................................................................25
3.CONCLUSION...........................................................................................26
4.CERTIFICATE...........................................................................................27
1. INTRODUCTION

WHAT IS CRUD?

CRUD is an acronym for CREATE, READ, UPDATE, and DELETE which are basic
functions of persistent storage. CRUD operations can use forms or an interface view to
retrieve and return data from a database.

WHAT IS JDBC?
Java Database Connectivity or JDBC API provides industry-standard and database-
independent connectivity between the Java applications and relational database servers
(relational databases, spreadsheets, and flat files). To keep it simple, JDBC allows a
Java application to connect to a relational database. The major databases are supported
such as Oracle, Microsoft SQL Server, DB2 and many others .

FUNDATMENTAL STEPS IN JDBC

The fundamental steps involved in the process of connecting to a database and executing
a query consist of the following:

1. Import JDBC packages

2. Load and register the JDBC driver

3. Open a connection to the database.

4. Create a statement object to perform a query.

5. Execute the statement object and return a query resultset.

6. Process the resultset.

7. Close the resultset and statement objects.

8. Close the connection.


Page |1
From above the steps, we actually require below five steps to connect a Java application
to the database
1. Import JDBC packages
2. Open a connection to the database.
3. Create a statement object to perform a query.
4. Execute the statements object and return a query resultset.
5. Process the result.

JDBC API

The JDBC API is comprised of two packages:

• java.sql
• javax.sql

JDBC API consists of two parts – the first part is the JDBC API to be used by the
application programmers. The second part is the low-level API to connect to a database
server.
The first part of JDBC API is part of standard java packages in java.sql package. We
use java.sql package API for accessing and processing data stored in a data source (usually
a relational database) using the Java programming language.

For the second part is the JDBC driver(there are four different types of JDBC drivers) A
JDBC driver is a set of Java classes that implement the JDBC interfaces, targeting a
specific database. The JDBC interfaces come with standard Java, but the implementation
of these interfaces is specific to the database you need to connect to. Such an
implementation is called a JDBC driver.

Page |2
2. DAILY REPORT

FIRST DAY
The First Day was a fresh experience to us. We all were welcomed and greeted in a very
well manner. The class was really interesting. The class started with an introduction
about SPECTRUM SOFTTECH SOLUTIONS PVT.LTD by its Manager Mr. Jibu John
who is a IT and Health Care Training. Rest of the session was about CRUD operations
in Java conducted by the Android Developer Cum Trainer Mrs. Sreelakshmi Sajeevan.

What are CRUD operations?

The CRUD stands for Create, Read/Retrieve, Update and Delete. These are the four
basic functions of the persistence storage. CRUD operations can use forms or an
interface view to retrieve and return data from a database.

Procedures Function
CREATE This is a form view to create a new
record in the database.

READ Reads the table records based on the


primary key within the input
parameter.

UPDATE Updates the content of the table


based on the specified primary key
for a record.

DELETE Deletes a specified row in the


table.

Page |3
The following tools are used for the development:

1. Eclipse IDE for Java EE Developers:- Eclipse is an integrated development


environment used in computer programming. It contains a base workspace and an
extensible plug-in system for customizing the environment. It is the second-most-
popular IDE for Java development, and, until 2016, was the most popular.

2. Apache Tomcat:- Apache Tomcat is a free and open-source implementation of the


Jakarta Servlet, Jakarta Expression Language, and Web Socket technologies. Tomcat
provides a "pure Java" HTTP web server environment in which Java code can run.

3. JDK:- The Java Development Kit (JDK) is a distribution of Java Technology by


Oracle Corporation. It implements the Java Language Specification (JLS) and the Java
Virtual Machine Specification (JVMS) and provides the Standard Edition (SE) of the
Java Application Programming Interface (API).

4. MySQL Connector for Java:- MySQL provides connectivity for client applications
developed in the Java programming language with MySQL Connector/J, a driver that
implements the Java Database Connectivity (JDBC) API. MySQL Connector/J is a
JDBC Type 4 driver. Different versions are available that are compatible with the JDBC
3.0 and JDBC 4.

5. JDBC:- JDBC stands for Java Database Connectivity. JDBC is a Java API to connect
and execute the query with the database. It is a part of JavaSE (Java Standard Edition).
JDBC API uses JDBC drivers to connect with the database.

Page |4
6. SQLyog:- SQLyog is a powerful MySQL development and administration solution,
trusted by 2.5 million users around the world. With SQLyog, organizations have a tool
that enables database developers, administrators, and architects to visually compare,
optimize, and document schemas.

7. XAMPP:- XAMPP is a software distribution which provides the Apache web server,
MySQL database (actually MariaDB), PHP and Perl (as command-line executable and
Apache modules) all in one package. It is available for Windows, MAC and Linux
systems.

Page |5
SECOND DAY :

In the second day we were moved to the next step, designing. Here we know about
different control and their important properties that we used for designing.

EMPLOYEE MANAGEMENT SYSTEM

In this project Employee Management System Project is essential software designed to


keep track of employee information in any company. It stores data such as their
employees’ personal information. This simple crud employee system is a simple Java
applet program. This system is basically an employee management system but with the
JDBC driver database. Here you can perform the CRUD operations. This whole system is
built in Java programming language with the help of Eclipse IDE.

USER INTERFACE (UI)


First we create the user interface to add the details of the employees.

Page |6
SOURCE CODE

HomePage.html:

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Home</title>
</head>
<body>
<h1>Add New Employee</h1>
<form action="SaveServlet" method="post">
<table>
<tr><td>Name:</td><td><input type="text" name="name"/></td></tr>
<tr><td>Password:</td><td><input type="password" name="password"/
></td></tr>
<tr><td>Email:</td><td><input type="email" name="email"/></td></tr>
<tr><td>Country:</td><td>
<select name="country" style="width:150px">
<option>India</option>
<option>USA</option>
<option>UK</option>
<option>Other</option>
</select>
</td></tr>
<tr><td colspan="2"><input type="submit" value="Save Employee"/></td>
</tr>
</table> </form>

Page |7
<br/>
<a href="ViewServlet">view employees</a>
</body>
</html>

Emp.java:

public class Emp {


private int id;
private String name,password,email,country;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

Page |8
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}

We need a class that helps to perform CRUD operations on our database

EmpDao.java:

import java.util.*;
import java.sql.*;
public class EmpDao {

public static Connection getConnection(){


Connection con=null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","syst
em","oracle");

Page |9
}catch(Exception e){System.out.println(e);}
return con;
}
public static int save(Emp e){
int status=0;
try{
Connection con=EmpDao.getConnection();
PreparedStatement ps=con.prepareStatement(
"insert into user905(name,password,email,country) values (?,?,?,?)");
ps.setString(1,e.getName());
ps.setString(2,e.getPassword());
ps.setString(3,e.getEmail());
ps.setString(4,e.getCountry());

status=ps.executeUpdate();

con.close();
}catch(Exception ex){ex.printStackTrace();}

return status;
}
public static int update(Emp e){
int status=0;
try{
Connection con=EmpDao.getConnection();
PreparedStatement ps=con.prepareStatement(
"update user905 set name=?,password=?,email=?,country=? where
id=?");

P a g e | 10
ps.setString(1,e.getName());
ps.setString(2,e.getPassword());
ps.setString(3,e.getEmail());
ps.setString(4,e.getCountry());
ps.setInt(5,e.getId());

status=ps.executeUpdate();

con.close();
}catch(Exception ex){ex.printStackTrace();}

return status;
}
public static int delete(int id){
int status=0;
try{
Connection con=EmpDao.getConnection();
PreparedStatement ps=con.prepareStatement("delete from user905 where
id=?");
ps.setInt(1,id);
status=ps.executeUpdate();

con.close();
}catch(Exception e){e.printStackTrace();}

return status;
}
public static Emp getEmployeeById(int id){

P a g e | 11
Emp e=new Emp();

try{
Connection con=EmpDao.getConnection();
PreparedStatement ps=con.prepareStatement("select * from user905 where
id=?");
ps.setInt(1,id);
ResultSet rs=ps.executeQuery();
if(rs.next()){
e.setId(rs.getInt(1));
e.setName(rs.getString(2));
e.setPassword(rs.getString(3));
e.setEmail(rs.getString(4));
e.setCountry(rs.getString(5));
}
con.close();
}catch(Exception ex){ex.printStackTrace();}

return e;
}
public static List<Emp> getAllEmployees(){
List<Emp> list=new ArrayList<Emp>();

try{
Connection con=EmpDao.getConnection();
PreparedStatement ps=con.prepareStatement("select * from user905");
ResultSet rs=ps.executeQuery();
while(rs.next()){

P a g e | 12
Emp e=new Emp();
e.setId(rs.getInt(1));
e.setName(rs.getString(2));
e.setPassword(rs.getString(3));
e.setEmail(rs.getString(4));
e.setCountry(rs.getString(5));
list.add(e);
}
con.close();
}catch(Exception e){e.printStackTrace();}

return list;
}
}

After we create our Servlet classes, each servlet class for the Create user, Update
user, Read user and Delete user from the database. Here are the classes

SaveServlet.java:

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/SaveServlet")
P a g e | 13
public class SaveServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();

String name=request.getParameter("name");
String password=request.getParameter("password");
String email=request.getParameter("email");
String country=request.getParameter("country");

Emp e=new Emp();


e.setName(name);
e.setPassword(password);
e.setEmail(email);
e.setCountry(country);

int status=EmpDao.save(e);
if(status>0){
out.print("<p>Record saved successfully!</p>");
request.getRequestDispatcher("index.html").include(request, response);
}else{
out.println("Sorry! unable to save record");
}

out.close();
}
}

P a g e | 14
EditServlet.java:

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/EditServlet")
public class EditServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<h1>Update Employee</h1>");
String sid=request.getParameter("id");
int id=Integer.parseInt(sid);

Emp e=EmpDao.getEmployeeById(id);

out.print("<form action='EditServlet2' method='post'>");


out.print("<table>");
out.print("<tr><td></td><td><input type='hidden' name='id'
value='"+e.getId()+"'/></td></tr>");
out.print("<tr><td>Name:</td><td><input type='text' name='name'
value='"+e.getName()+"'/></td></tr>");
out.print("<tr><td>Password:</td><td><input type='password' name='password'

P a g e | 15
value='"+e.getPassword()+"'/>
</td></tr>");
out.print("<tr><td>Email:</td><td><input type='email' name='email'
value='"+e.getEmail()+"'/></td></tr>");
out.print("<tr><td>Country:</td><td>");
out.print("<select name='country' style='width:150px'>");
out.print("<option>India</option>");
out.print("<option>USA</option>");
out.print("<option>UK</option>");
out.print("<option>Other</option>");
out.print("</select>");
out.print("</td></tr>");
out.print("<tr><td colspan='2'><input type='submit' value='Edit & Save
'/></td></tr>");
out.print("</table>");
out.print("</form>");

out.close();
}
}

EditServelet2.java:

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
P a g e | 16
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/EditServlet2")
public class EditServlet2 extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();

String sid=request.getParameter("id");
int id=Integer.parseInt(sid);
String name=request.getParameter("name");
String password=request.getParameter("password");
String email=request.getParameter("email");
String country=request.getParameter("country");

Emp e=new Emp();


e.setId(id);
e.setName(name);
e.setPassword(password);
e.setEmail(email);
e.setCountry(country);

int status=EmpDao.update(e);
if(status>0){
response.sendRedirect("ViewServlet");
}else{

P a g e | 17
out.println("Sorry! unable to update record");
}

out.close();
}

DeleteServelet.java:

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/DeleteServlet")
public class DeleteServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String sid=request.getParameter("id");
int id=Integer.parseInt(sid);
EmpDao.delete(id);
response.sendRedirect("ViewServlet");
}
}

P a g e | 18
ViewServlet.java:

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/ViewServlet")
public class ViewServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<a href='index.html'>Add New Employee</a>");
out.println("<h1>Employees List</h1>");

List<Emp> list=EmpDao.getAllEmployees();

out.print("<table border='1' width='100%'");


out.print("<tr><th>Id</th><th>Name</th><th>Password</th><th>Email</th><th>
Country</th>
<th>Edit</th><th>Delete</th></tr>");
for(Emp e:list){
out.print("<tr><td>"+e.getId()+"</td><td>"+e.getName()+"</td><td>"+e.getPass
word()+"</td>
P a g e | 19
<td>"+e.getEmail()+"</td><td>"+e.getCountry()+"</td><td><a
href='EditServlet?id="+e.getId()+"'>edit</a></td>
<td><a href='DeleteServlet?id="+e.getId()+"'>delete</a></td></tr>");
}
out.print("</table>");

out.close();
}
}

P a g e | 20
Output

First page will look like this, fill the form and submit it.

Figure 2.1

You will get a message “Record successfully saved”

Figure 2.2
P a g e | 21
Click on the View Employees link to see the total employees list

Figure 2.3

Click on the update link, to change the data

Figure 2.4

P a g e | 22
After changing information, submit button. You will see that information is
changed

Figure 2.5

Now, click heading on the delete link to delete the record

Figure 2.6
P a g e | 23
THIRD DAY:

The final day of the Industrial visit. We successfully perform the CRUD operations and
tested the web application using Apache Tomcat Server and XAMPP.

A viva examination was conducted based on the topics that we are taught. It was led by
Sreelakshmi Sajeevan.

P a g e | 24
3. CONCLUSION

The Industrial Visit to SPECTRUM SOFTWARE SOLUTIONS helped us to learn a lot


of things which we had never learned from our academic. The culture of the organization,
office etiquettes and unique management model gave us a deep insight about industry
standards. This visit provided us an opportunity to identify, observe and practice how
engineering is applicable in the real industry. This training make us capable of doing
project by our own. Also, this Industrial Visit helped us for better understanding what we
going to face in future and to gain lot of knowledge needed be to successful in a great
engineering challenge. We hope it will definitely pave our way to success.

P a g e | 25
P a g e | 26

You might also like