0% found this document useful (0 votes)
58 views7 pages

To Create A College Management System Using Servlets With JDBC Ex - No:2.3b Date

The document describes developing a web application for a college management system using servlets and JDBC. It involves creating a module for new staff registration that allows collecting staff name, employee number, qualifications, and designation from the admin. The details are stored in a database table. Upon registration, the staff details are printed to confirm registration. The program implements this module by creating HTML and servlet code to: 1) accept input, 2) connect to a database, 3) create and populate a table, 4) query the table, and 5) output the results. The project goal of creating the college management system module and performing the required operations was achieved.

Uploaded by

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

To Create A College Management System Using Servlets With JDBC Ex - No:2.3b Date

The document describes developing a web application for a college management system using servlets and JDBC. It involves creating a module for new staff registration that allows collecting staff name, employee number, qualifications, and designation from the admin. The details are stored in a database table. Upon registration, the staff details are printed to confirm registration. The program implements this module by creating HTML and servlet code to: 1) accept input, 2) connect to a database, 3) create and populate a table, 4) query the table, and 5) output the results. The project goal of creating the college management system module and performing the required operations was achieved.

Uploaded by

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

Ex.No:2.

3b
Date:

To Create a College Management System using


Servlets with Jdbc

Question:
Develop a web application using HTML &Servlets for the given scenario below:
(Required database tables implementation must be done)
Consider you need to create a module in the project College Management system. In your
module you need to create the option for new staff registration by getting the staffs Name,
employee no, qualification and designation from the admin. You have to include the facility to
store and maintain all the details in database table. To give the conformation to the admin about
new faculty registration, print the staffs registration details at the end of your module execution.
Implement your module.

Aim:
To create a module in the project College Management system and perform the given
operations.

Program:
<!DOCTYPE html>
<html>
<head>
<title>LIBRARY MANAGEMENT SYSTEM</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form name="BOOK" method="get" action="http://localhost:8080/twopointthree/dbtwo">
<h1>LIBRARY MANAGEMENT SYSTEM </h1><br><h3>ACCESS NUMBER</h3>
<BR>
<pre>

ENTER BOOK ACCESS NUMBER

<input type="text" name="book"

id="1"><br>
<input type="submit" value="submit"/>

<input type="reset" value="reset"/>

</pre>
</form>
</body>
</html>

PROGRAM 2:

import java.sql.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class dbtwo extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String book=request.getParameter("book");

Connection con = null;


try
{
Class.forName("org.apache.derby.jdbc.ClientDriver");
con =DriverManager.getConnection("jdbc:derby://localhost:1527/sample", "app", "app");
Statement st = con.createStatement();
String q="drop table book";
st.execute(q);
q= "create table book(bname varchar(20),access varchar(6),author varchar(20),publisher
varchar(20),price varchar(5))";
st.execute(q);
q="insert into book values('JAVA','350','schildt','TATA','500')";
st.executeUpdate(q);
q="insert into book values('C','240','schildt','TATA','500')";
st.executeUpdate(q);
q="insert into book values('C#','300','schildt','TATA','500')";
st.executeUpdate(q);
q="insert into book values('C++','330','schildt','TATA','500')";
st.executeUpdate(q);
q="select * from book where access='"+book+"'";
ResultSet r = st.executeQuery(q);
while(r.next())
{
out.println("<html><head></head><body>");

out.println("<table border='3'><tr bgcolor='CCFF66'><th>BOOK


NAME</th><th>ACCESS
NUMBER</th><th>AUTHOR</th><th>PUBLISHER</th><th>PRICE</th></tr>");
out.println("<tr bgcolor='gold'>");
out.println("<td>"+r.getString("bname")+"</td>");
out.println("<td>"+r.getString("access")+"</td>");
out.println("<td>"+r.getString("author")+"</td>");
out.println("<td>"+r.getString("publisher")+"</td>");
out.println("<td>"+r.getString("price")+"</td></tr>");
out.println("</table></body></html>");
}

}
catch(SQLException e)
{
out.println(e);
}
catch(ClassNotFoundException e)
{
out.println(e);
}
catch(Exception e)
{
out.println(e);
}
finally

{
try {
con.close();
} catch (Exception ex) {
Logger.getLogger(dbone.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}

Output:

Result:
Thus the project College Management system was created and performed the given
operations successfully.

You might also like