2. Write a JSP application to
evaluate the salary details of an employee and store the same in the MS Access database table.
<!-- 10. JSP Program to Evaluate Salary Details of an Employee and Store in Database.--><html>
<head>
<%@ page import="java.sql.*" %>
</head>
<body bgcolor="beige">
<%
String ename="Mahesh";
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
{
out.println("<h2>Information Stored Successfully!</h2>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:emp10");
Statement st=con.createStatement();
String s="insert into emp10 values('"+ename+"','"+dept+"','"+des+"',"
+bsal+","+gsal+","+netsal+");";
st.executeQuery(s);
}
catch(Exception e)
{
//out.println(e);
}
%>
</body>
</html>
No comments :
Post a Comment