Filename: Employee15.jsp
<!-- 15. JSP Program to Evaluate Salary Details of an Employee and Store into Database. -->
<html>
<head>
<%@ page import="java.sql.*" %>
</head>
<body bgcolor="beige">
<%
String ename="Mahesh7";
String dept="Finance";
String des="Manager";
double bsal=20000;
double ta=10;
double da=30;
double hra=10;
double pf=10;
double lic=15;
double allowance;
double deduction;
double gsal;
double netsal;
allowance = (bsal*ta)/100 + (bsal*da)/100 + (bsal*hra)/100;
deduction = (bsal*pf)/100 + (bsal*lic)/100;
gsal = bsal + allowance;
netsal = gsal - deduction;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:sal15");
Statement st=con.createStatement();
String s="insert into sal15 values('"+ename+"','"+dept+"','"+des+"',"
+bsal+","+allowance+","+gsal+","+deduction+","+netsal+");";
out.println("<h3>Employee Details Stored in the Database Successfully!</h3>");
st.executeQuery(s);
}
catch(Exception e)
{
//out.println(e);
}
%>
</body>
</html>
<!-- 15. JSP Program to Evaluate Salary Details of an Employee and Store into Database. -->
<html>
<head>
<%@ page import="java.sql.*" %>
</head>
<body bgcolor="beige">
<%
String ename="Mahesh7";
String dept="Finance";
String des="Manager";
double bsal=20000;
double ta=10;
double da=30;
double hra=10;
double pf=10;
double lic=15;
double allowance;
double deduction;
double gsal;
double netsal;
allowance = (bsal*ta)/100 + (bsal*da)/100 + (bsal*hra)/100;
deduction = (bsal*pf)/100 + (bsal*lic)/100;
gsal = bsal + allowance;
netsal = gsal - deduction;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:sal15");
Statement st=con.createStatement();
String s="insert into sal15 values('"+ename+"','"+dept+"','"+des+"',"
+bsal+","+allowance+","+gsal+","+deduction+","+netsal+");";
out.println("<h3>Employee Details Stored in the Database Successfully!</h3>");
st.executeQuery(s);
}
catch(Exception e)
{
//out.println(e);
}
%>
</body>
</html>
No comments :
Post a Comment