db name:mytestdb CREATE TABLE studentplacement ( id int(5) auto_increment, registernumber varchar(10), name varchar(50), course varchar(50), placememntmode varchar(50), employertype varchar(50), selectiondate varchar(50), package varchar(50), PRIMARY KEY (id ) );
register number | 1 |
student name | raj |
course | bca |
placememntmode | oncampus |
company | IBM |
employertype | private |
selectiondate | 4/8/2021 |
package | 6,00,000 |
STUDENT INFORMATION
Question:
- Your college wants to keep a record of student placements.
- Design a user interface to accept.
-
Student name,
Register number,
Course, Combination,
-
Placement Mode (On campus, offcampus),
Name of the company (or office),
Employer Type (Private, Government),
Selectiondate, Package.
-
The accepted data should be recorded in the database table (the choice of
database management system is open except MS-Access).
-
Write a JSP program for the purpose. Verify every omission and errors in feeding the data.
-
STUDENT INFORMATION
<%@ page import="java.sql.*,java.util.*"%>
<%@ page import="java.io.*" %>
STUDENT INFORMATION IS STORED SUCCESSFULLY
STUDENT INFORMATION
<%
//int ID=Integer.parseInt(request.getParameter("pid"));
String studentname=request.getParameter("studentname");
String registernumber=request.getParameter("registernumber");
String course=request.getParameter("course");
String placememntmode=request.getParameter("placememntmode");
String company=request.getParameter("company");
String employertype=request.getParameter("employertype");
String selectiondate=request.getParameter("selectiondate");
String packagepr=request.getParameter("package");
out.print(" ");
out.println("register number "+registernumber+" ");
out.println("student name "+studentname+" ");
out.println("course "+course+" ");
out.println("placememntmode "+placememntmode+" ");
out.println("company "+company+" ");
out.println("employertype "+employertype+" ");
out.println("selectiondate "+selectiondate+" ");
out.println("package "+packagepr+" ");
out.print("
");
try {
String connectionURL = "jdbc:mysql://localhost:3306/mytestdb";
Class.forName("com.mysql.jdbc.Driver") .newInstance();
Connection connecion = DriverManager
.getConnection(connectionURL,"root","");
PreparedStatement p=connection.prepareStatement("insert into studentplacement values('"+registernumber+"','"+studentname+"','"+course+"',
'"+placememntmode+"','"+company+"','"+employertype+"','"+selectiondate+"','"+packagepr+"')");
int rs=p.executeUpdate();
if(rs>0)
{
out.print("DATA INSERTED SUCCESSFULLY");
}
else
{
out.print(" NOT CONNECTED");
}
if(!connection.isClosed())
out.println("Successfully connected to " + "MySQL server using TCP/IP...");
connection.close();
}
catch(Exception ex){
out.println("Unable to connect to database.");
}
%>