postheadericon Be a freelancers and become your own Boss

Are you looking for good Job?
Do you interested to earn dollars?
Are you satisfied with your daily hectic schedule of Job?
Are you interested to work form your home or what ever the place you like?


What your answer is yes !!!

here is the solution

Be a Freelancer and become your own boss




Just read article of The Economic Times
 


postheadericon Vacancy for IT Peoples in Indian Navy


Join Indian Navy

our Indian Navy invites unmarried Male to join Navy a (SSC) Officers in Executive Branch (Information Technology)  for December-2012 Course

postheadericon 28. Develop a program to perform the database driven operation like insert, Delete, Update and select. To perform the above operations create one table named Employee.


Create Table in MySql [ Employee ]


CREATE TABLE  `wtad`.`Employee` (
`EmpId` INT( 4 ) NOT NULL ,
`Empname` VARCHAR( 15 ) NOT NULL ,
`Emp_desig` VARCHAR( 20 ) NOT NULL ,
`Emp_J_Date` VARCHAR( 20 ) NOT NULL ,
`Emp_Salary` INT( 8 ) NOT NULL
) ENGINE = MYISAM ;

postheadericon 30. Write a Java application to invoke a stored procedure using a CallableStatement. For this a stored procedure called incrementSalary may be developed to increase all the employees salary by a percentage specified in the parameter.



Create Procedure in Oracle




create or replace procedure incrementSalary(percent IN NUMBER)
is
BEGIN
    UPDATE Employee
    SET Emp_Salary = Emp_Salary + (Emp_Salary *( percent/100));
    commit;

END incrementSalary;


index.jsp




<html>
<head>
<title> Ex-30 : www.BipinRupadiya.blogspot.in</title>
<LINK REL="STYLESHEET" HREF="myCss.css" TYPE="text/css">
<script>
function frmValidate(frm)
{
if(frm.txtPer.value.trim()=="")
{
alert("Enter Percentage : ");
frm.txtPer.focus();
return false;
}
if(isNaN(frm.txtPer.value))
{
alert("Invalid Percentage : ");
frm.txtPer.focus();
return false;
}
return true;
}
</script>
</head>

<body>
<center>
<div class="abc"  id="f1" align="center">
<br>
<form method="POST" action="incSal.jsp" onSubmit="return frmValidate(this)">
<table align="center">
<tr>
<td colspan=2 align=center>
<h3>Employee </h3>
<hr>
</td>
</tr>

<tr>
<td>Increment Salary by Percentage : </td>
<td><input type="text" name="txtPer" size="3" onkeypress='return isNum(event)'>%</td>
</tr>

<tr>
<td colspan=2 align=center>
<hr>
<input type="hidden" name="action" value="incSal">
<input type="submit" value="Increment Salary">
<input type="reset" value="Clear">
</td>
</tr>
</table>
</form>
</div>
</center>
</body>
</html>


incSal.jsp




<%@ page import="java.sql.*" %>
<%!
String className= "oracle.jdbc.driver.OracleDriver";
String url= "jdbc:oracle:thin:@localhost:1521:xe";
String user= "scott";
String password= "tiger";
String action="x";
%>
<%
try
{
Class.forName(className);
Connection con= DriverManager.getConnection(url, user, password);

CallableStatement cs=con.prepareCall("{ call incrementSalary(?)}");
cs.setDouble(1,Double.parseDouble(request.getParameter("txtPer")));

int ans=cs.executeUpdate();

ServletContext context= getServletContext();
RequestDispatcher rd= context.getRequestDispatcher("/index.jsp");
if(ans!=0)
{
out.println("<div class=errorG>Salary Successfully updated</div>");
}
else
{
out.println("<div class=errorR>Problem in update</div>");
}
rd.include(request, response);

cs.close();
con.close();
}
catch(Exception e)
{
out.println(""+e);
}
%>


myCss.css


.abc
{
background:#ababff;
position:absolute;
top:2in;
--height : 200px;
width:300px;
left:5in;
border-style:solid;
}
.errorG
{
background:#00Fa00;
position:absolute;
top:1in;
height:30px;
width:300px;
left:5in;
padding-top:10px;
color:#000000;
border-color:#000000;
border-style:dotted;
font-size: 13pt ;
text-align:center ;
}
.errorR
{
background:#Fa0000;
position:absolute;
top:1in;
height:30px;
width:300px;
left:5in;
padding-top:10px;
color:#000000;
border-color:#000000;
border-style:dotted;
font-size: 13pt ;
text-align:center ;
}



postheadericon 16. Assume that the information regarding the marks for all the subjects of a student in the last exam are available in a database, Develop a Servlet which takes the enrollment number of a student as a request parameter and displays the marksheet for the student.



1. Create Database in MySql / Oracle / Access


You can choose any database. Here, I provide the solution to connect database like MySQL, Oracle,    and Microsoft Access




2. Create Table IN MySQL
create table MARK (EnNo VARCHAR(10),Code VARCHAR(10),Name VARCHAR(10),Mark INT(3));


3. Create Table IN Oracle
create table MARK (EnNo VARCHAR(10),Code VARCHAR(10),Name VARCHAR(10),Mark NUMBER (3));


    


4. Create Web Application in tomcat using following code              


index.jsp





<HTML>  
<HEAD>  
<TITLE>Ex-16 : www.BipinRupadiya.blogspot.in</TITLE>  
<style>
.abc
{
background:#ababff;
position:absolute;
top:2in;
hieght:200px;
width:400px;
left:5in;
border-style:solid;
}
</style>

</HEAD>  
<BODY>
<div class="abc"  id="f1">
<br>
<center>
<h3>
<FORM METHOD=POST ACTION="Ex16.com">
Enrollment No.: <input type=TEXT name = "txtEnNo" >
<BR><BR><input type="submit" value="Show Result">
</FORM>
</div>
</BODY>
</HTML>


Ex16.java





import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import javax.servlet.annotation.WebServlet;

@WebServlet("/Ex16.com")
public class Ex16 extends HttpServlet
{
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
String enNo = request.getParameter("txtEnNo");
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        try
{
//Connect To MySql
/* Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/wtad","root","admin");

*/
//Connect To Oracle

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","scott","tiger");


//Connect To Access
/*
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:test","bipin","rupadiya");
*/


String sql = "select * from MARK where EnNo = ?";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1, enNo);

ResultSet rs= ps.executeQuery();

out.println("<HTML><BODY bgcolor='#ababff'>");
            out.println("<center><h1> Marksheet</h1>");
            out.println("<TABLE BORDER=1 cellpadding='5px' width=50%");

out.println("<TR><TH colspan=3> Enrollment No.:"+enNo+"</TH></TR>");
out.println("<TR><TH>CODE </TH> <TH>NAME </TH> <TH> GRADE </TH></TR>");

            if(rs == null)
            {  
                out.println("<h1> Result Not Found... </h1>");
            }
            else
            {
while(rs.next())
                {
                    out.println("<TR>");
                        out.println("<TD>"+rs.getString(2)+"</TD>");
out.println("<TD>"+rs.getString(3)+"</TD>");
out.println("<TD>"+rs.getInt(4)+"</TD>");                          
                    out.println("</TR>");
                }
out.println("<TR><TH colspan=3> <a href='index.jsp'>Home</a> </TH></TR>");
out.println("</TABLE></CENTER></BODY></HTML>");
                rs.close();
                ps.close();
                con.close();
            }
        }
        catch(SQLException e)
        {
                out.println(e);
        }
catch(ClassNotFoundException e)
{
out.println(e);
}
        catch(Exception e)
        {
            out.println(e);
        }    

    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        doGet(request, response);
    }
}






Total Pageviews

© BipinRupadiya.com. Powered by Blogger.