hospital management
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %> <!DOCTYPE html> <html> <body> <form action="rejijav.jsp"> <table border="2" align="center"> <tr><td>id</td><td><input type="text" name="id" class="txt"/></td></tr> <tr><td>fname</td><td><input type="text" name="fname" class="txt"/></td></tr> <tr><td>lname</td><td><input type="text" name="lname" class="txt"/></td></tr> <tr><td>age</td><td><input type="text" name="age" class="txt"/></td></tr> <tr><td>dob</td><td><input type="text" name="dob" class="txt"/></td></tr> <tr><td>address</td><td><input type="text" name="address" class="txt"/></td></tr> <tr><td><input type="submit" value="submit"/></td></tr> </table> <% Connection con; Statement st; ResultSet rs; PreparedStatement pst=null; String id,lname,fname,age,dob,address; id=request.getParameter("id"); fname=request.getParameter("fname"); lname=request.getParameter("lname"); age=request.getParameter("age"); dob=request.getParameter("dob"); address=request.getParameter("address"); if(id!=null && id!="") { int id1=Integer.parseInt(id); try { String Url="jdbc:mysql://localhost:3306/mobile"; Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection(Url,"root","root123"); st=con.createStatement(); if(fname!=null && fname!="") { pst=con.prepareStatement("update register set fname=? where id=?"); pst.setString(1,fname); pst.setInt(2,id1); pst.executeUpdate(); } if(lname!=null && lname!="") { pst=con.prepareStatement("update register set lname=? where id=?"); pst.setString(1,lname); pst.setInt(2,id1); pst.executeUpdate(); } if(age!=null && age!="") { int age1=Integer.parseInt(age); pst=con.prepareStatement("update register set age=? where id=?"); pst.setInt(1,age1); pst.setInt(2,id1); pst.executeUpdate(); } if(dob!=null && dob!="") { pst=con.prepareStatement("update register set dob=? where id=?"); pst.setString(1,dob); pst.setInt(2,id1); pst.executeUpdate(); } if(address!=null && address!="") { pst=con.prepareStatement("update register set address=? where id=?"); pst.setString(1,address); pst.setInt(2,id1); pst.executeUpdate(); } out.print("Sucessfull!!!"); }catch(Exception e) { out.print(e); } }%> </form> </body> </html>
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %> <!DOCTYPE html> <html> <body> <form action="rejijav.jsp"> <table border="2" align="center"> <tr><td>id</td><td><input type="text" name="id" class="txt"/></td></tr> <tr><td>fname</td><td><input type="text" name="fname" class="txt"/></td></tr> <tr><td>lname</td><td><input type="text" name="lname" class="txt"/></td></tr> <tr><td>age</td><td><input type="text" name="age" class="txt"/></td></tr> <tr><td>dob</td><td><input type="text" name="dob" class="txt"/></td></tr> <tr><td>address</td><td><input type="text" name="address" class="txt"/></td></tr> <tr><td><input type="submit" value="submit"/></td></tr> </table> <% Connection con; Statement st; ResultSet rs; PreparedStatement pst=null; String id,lname,fname,age,dob,address; id=request.getParameter("id"); fname=request.getParameter("fname"); lname=request.getParameter("lname"); age=request.getParameter("age"); dob=request.getParameter("dob"); address=request.getParameter("address"); if(id!=null && id!="") { int id1=Integer.parseInt(id); try { String Url="jdbc:mysql://localhost:3306/mobile"; Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection(Url,"root","root123"); st=con.createStatement(); if(fname!=null && fname!="") { pst=con.prepareStatement("update register set fname=? where id=?"); pst.setString(1,fname); pst.setInt(2,id1); pst.executeUpdate(); } if(lname!=null && lname!="") { pst=con.prepareStatement("update register set lname=? where id=?"); pst.setString(1,lname); pst.setInt(2,id1); pst.executeUpdate(); } if(age!=null && age!="") { int age1=Integer.parseInt(age); pst=con.prepareStatement("update register set age=? where id=?"); pst.setInt(1,age1); pst.setInt(2,id1); pst.executeUpdate(); } if(dob!=null && dob!="") { pst=con.prepareStatement("update register set dob=? where id=?"); pst.setString(1,dob); pst.setInt(2,id1); pst.executeUpdate(); } if(address!=null && address!="") { pst=con.prepareStatement("update register set address=? where id=?"); pst.setString(1,address); pst.setInt(2,id1); pst.executeUpdate(); } out.print("Sucessfull!!!"); }catch(Exception e) { out.print(e); } }%> </form> </body> </html>
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body > <form action="delete2.jsp"> <table> <tr><td>id</td><td><input type="text" name="id" class="txt"/></td></tr> </table> <input type="submit" value="Delete"/> </form> <% Connection con; Statement st; PreparedStatement pst=null; String id=request.getParameter("id"); if(id!=null && id!="") { int id1=Integer.parseInt(id); try { String Url="jdbc:mysql://localhost:3306/mobile"; Class.forName("com.mysql.jdbc.Driver"); con=DriverManager.getConnection(Url,"root","root123"); st=con.createStatement(); pst=con.prepareStatement("delete from register where id=?"); pst.setInt(1,id1); pst.executeUpdate(); out.println("Deleted Sucessfully"); }catch(Exception e) { out.print(e); } }%> </body> </html>
Ads