0

Hello friends,
I am working with jsp and oracle database and The problem is after inserting 3 enteries(rows) through form filling into database next enteries are not going in databse.So please suggest me something.

3
Contributors
3
Replies
6
Views
5 Years
Discussion Span
Last Post by anand01
0

newrecord.jsp

<%@page contentType="text/html"%>
<%@page contentType="text/html" import="java.util.*" %>
<%@page import="java.io.*" %>
<%@page import="java.sql.*" %>
<%@page import="javax.swing.*" %>


<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Patient </title>
    </head>
    <body>
<script language="javascript">
function validate()
{
    var chks = document.getElementsByName('issue[]');
    var hasChecked = false;
    for (var i = 0; i < chks.length; i++)
    {
        if (chks[i].checked)
        {
        hasChecked = true;
        break;
        }
    }
    return true;
}

</script>
<script>
function addDate(){
date = new Date();
var month = date.getMonth()+1;
var day = date.getDate();
var year = date.getFullYear();

if (document.getElementById('date').value == ''){
document.getElementById('date').value = day + '-' + month + '-' + year;
}
}
</script>



    <center>
        <h1>Patient Information</h1>
    </center>
    <table border="1" align="center" >
        <tr>
             <form  action="newsubmit.jsp" method="post">
                 <tr>
                     <td>

                         <select name="m1">
                             <option name="m"value="mr">Mr.</option>
                             <option name="m"value="mrs">Mrs.</option>
                             <option name="m"value="ms">Ms.</option>
                         </select>
                         First Name:<input type="text"  name="fname">
                 Middle Name:<input type="text"  name="mname">
                 Last Name:<input type="text"  name="lname">
                         Gender:<select name="gender">
                             <option name="m1"value="mr">Male</option>
                             <option name="m1"value="mrs">Female</option>
                         </select></br>
                     </td>
                 </tr>   
                 <tr>
                     <td>
                      Register No:<input type="text"  name="regno"></br>
                 </td>
                 </tr>

                 <tr>
                     <td>
                         Age:<input type="text"  name="age">
                         Occupation:<input type="text"  name="occupation"></br>
                     </td>
                 </tr>
         <tr>
                     <td>
                        Address: <textarea name="address"> </textarea></br>
                     </td>
                 </tr>
                  <tr>
                     <td>
                         Phone No:<input type="text"  name="phone">
                         <body onload="addDate();">
                            Visit Date is: <input type="text" id="date" name="vdate">
                            </body>
                        </br>

                     </td>
                 </tr>
                 <tr>
                     <td>

                            Past History of major issues: <br>
                            <input type="checkbox" name="issue" value="chickenpox" >Chickenpox <br> 
                            <input type="checkbox" name="issue" value="measles" >Measles <br>
                            <input type="checkbox" name="issue" value="typhoid" >Typhoid <br>

                    </td>
                </tr>
                <tr>
                    <td>

                        Present Major Illness: <br>
                        <textarea name="illness" rows=5,cols=5> </textarea></br>
                    </td>
                </tr>
                <tr>
                    <td>
                        Birth Date:<input type="text" name="dob"></br>
                        Health:</br>
                       <input type="radio" name="h"> Amla</br>
                         <input type="radio" name="h">Saar</br>
                         <input type="radio" name="h"> Sandha</br>
                        <input type="radio" name="h">Ubhay</br>

                     </td>
                 </tr>
                 <tr>
                     <td>
                        Symtoms About:</br>
                        Heat:<textarea name="heat"></textarea>
                        Sleep:<textarea name="sleep"></textarea>
                        Urine:<textarea name="urine"></textarea>
                        Faeces:<textarea name="faeces"></textarea>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         About Stomach :</br>
                         Liver:<textarea name="liver"></textarea>
                         Ple:<textarea name="ple"></textarea></br>
                         Kidney:<textarea name="kidney"></textarea>
                         Apankaksha:<textarea name="apankaksha"></textarea></br>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         Other Symptoms:</br>

                         <input type="text"  name="s1"> 
        <input type="text"  name="s2"> 
        <input type="text"  name="s3"> 
        <input type="text"  name="s4"> 
        <input type="text"  name="s5"> </br></br>
        <input type="text"  name="s6"> 
        <input type="text"  name="s7"> 
        <input type="text"  name="s8"> 
        <input type="text"  name="s9"> 
        <input type="text"  name="s10"> </br>
    Symtoms since Days:<input type="text" name="day"></br>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         Previous Investigation Reports if any:</br>
                         <textarea name="report"></textarea>
                         Treatment :<textarea name="treatment"></textarea>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         Medicines:</br>
                         <select name="b1">
                              <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                         For weeks:<input type="text" name="w1">

                         <select name="b2">
                             <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                          For weeks:<input type="text" name="w2">
                         <select name="b3">
                             <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                          For weeks:<input type="text" name="w3">
                         <select name="b4">
                             <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                          For weeks:<input type="text" name="w4"></br>
                         <select name="b5">
                             <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                          For weeks:<input type="text" name="w5">

                         <select name="b6">
                             <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                          For weeks:<input type="text" name="w6">
                         <select name="b7">
                             <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                          For weeks:<input type="text" name="w7">
                         <select name="b8">
                             <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                          For weeks:<input type="text" name="w8"></br>
                         <select name="b9">
                             <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                          For weeks:<input type="text" name="w9">
                         <select name="b10">
                             <option name="a"value=""></option>
                             <option name="a"value="fridge">fridge</option>
                             <option name="a"value="car">car</option>
                             <option name="a"value="TV">TV</option>
                             <option name="a"value="Mobile">Mobile</option>
                             <option name="a"value="Computer">Computer</option>
                         </select>
                          For weeks:<input type="text" name="w10">
        </br>
        </br>
                     </td>
                 </tr>
                 <tr>
                     <td>
                         <input type="submit" value="submit" name="submit">
                            </form>

                     </td>
                 </tr>     

        </tr>

    </table>

    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
        <!-- Let's welcome the user ${param.name} -->
        Hello ${param.name}!
    </c:if>
    --%>

    </body>
</html>












**#newsubmit.jsp#**





<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.io.*" %>
<%@page import="java.sql.*" %>
<%@page import="javax.swing.*" %>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>

    <h1>JSP Page</h1>
       <%
        try
        {
            String mr1=request.getParameter("m1");

            String fnm=request.getParameter("fname");
            String mnm=request.getParameter("mname");
            String lnm=request.getParameter("lname");
            String gender1=request.getParameter("gender");
            int rno=Integer.parseInt(request.getParameter("regno"));
            String age1=request.getParameter("age");
            String occupation1=request.getParameter("occupation");
             String address1=request.getParameter("address");
             String phone1=request.getParameter("phone");
            String vd=request.getParameter("vdate");
             String []pastissue=request.getParameterValues("issue");

             String illness=request.getParameter("illness");
            String dob1=request.getParameter("dob");
            String healthtype=request.getParameter("h");
            String heat=request.getParameter("heat");
            String sleep=request.getParameter("sleep");
            String urine=request.getParameter("urine");
            String faeces=request.getParameter("faeces");
            String liver=request.getParameter("liver");
            String ple=request.getParameter("ple");
            String kidney=request.getParameter("kidney");
            String apankaksha=request.getParameter("apankaksha");
            String sym1=request.getParameter("s1");
            String sym2=request.getParameter("s2");
            String sym3=request.getParameter("s3");
            String sym4=request.getParameter("s4");
            String sym5=request.getParameter("s5");
            String sym6=request.getParameter("s6");
            String sym7=request.getParameter("s7");
            String sym8=request.getParameter("s8");
            String sym9=request.getParameter("s9");
            String sym10=request.getParameter("s10");
            String day=request.getParameter("day");
            String report=request.getParameter("report");
            String treatment=request.getParameter("treatment");
            String m1=request.getParameter("b1");
            String w1=request.getParameter("w1");
            String m2=request.getParameter("b2");
            String w2=request.getParameter("w2");
            String m3=request.getParameter("b3");
            String w3=request.getParameter("w3");
            String m4=request.getParameter("b4");
            String w4=request.getParameter("w4");
            String m5=request.getParameter("b5");
            String w5=request.getParameter("w5");
            String m6=request.getParameter("b6");
            String w6=request.getParameter("w6");
            String m7=request.getParameter("b7");
            String w7=request.getParameter("w7");
            String m8=request.getParameter("b8");
            String w8=request.getParameter("w8");
            String m9=request.getParameter("b9");
            String w9=request.getParameter("w9");
            String m10=request.getParameter("b10");
            String w10=request.getParameter("w10");
    Class.forName ("oracle.jdbc.driver.OracleDriver"); 
        Connection con=DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:xe","hospital","hospital");
         %>Connected Successfully<% 
         PreparedStatement ps,ps2,ps3,ps4;
       ps2=con.prepareStatement("insert into course values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
        ps=con.prepareStatement("insert into patient values(?,?,?,?,?,?,?,?,?,?)");
      ps3=con.prepareStatement("insert into symtoms values(?,?,?,?,?,?,?,?,?,?,?,?)");
        ps4=con.prepareStatement("insert into medicine values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
         ps.setInt(1,rno);
          ps.setString(2,mr1);
        ps.setString(3,fnm);
        ps.setString(4,mnm);
        ps.setString(5,lnm);
        ps.setString(6,gender1);
         ps.setString(7,address1);
         ps.setInt(8,Integer.parseInt(phone1));
        ps.setInt(9,Integer.parseInt(age1));
          ps.setString(10,dob1);
          %><%=rno %><%
           ps.executeQuery();
         //ps.setString(11,rno);
         ps2.setInt(1,rno);
        ps2.setString(2,vd);
        ps2.setString(3,pastissue[1]);
        ps2.setString(4,pastissue[2]);
        ps2.setString(5,pastissue[3]);
        ps2.setString(6,illness);
        ps2.setString(7,dob1);
        ps2.setString(8,healthtype);
        ps2.setString(9,heat);
        ps2.setString(10,sleep);
        ps2.setString(11,urine);
        ps2.setString(12,faeces);
        ps2.setString(13,liver);
        ps2.setString(14,ple);
        ps2.setString(15,kidney);
        ps2.setString(16,apankaksha);
         ps2.setInt(17,Integer.parseInt(day));
        ps2.setString(18,report);
        ps2.setString(19,treatment);   
        ps2.executeQuery();

        ps3.setInt(1,rno);
        ps3.setString(2,vd);
        ps3.setString(3,sym1);
        ps3.setString(4,sym2);
        ps3.setString(5,sym3);
        ps3.setString(6,sym4);
        ps3.setString(7,sym5);
        ps3.setString(8,sym6);
        ps3.setString(9,sym7);
        ps3.setString(10,sym8);
        ps3.setString(11,sym9);
        ps3.setString(12,sym10);
       ps3.executeQuery();
        ps4.setInt(1,rno);
        ps4.setString(2,vd);
        ps4.setString(3,m1);
        ps4.setInt(4,Integer.parseInt(w1));
        ps4.setString(5,m2);
         ps4.setInt(6,Integer.parseInt(w2));
        ps4.setString(7,m3);
         ps4.setInt(8,Integer.parseInt(w3));
        ps4.setString(9,m4);
         ps4.setInt(10,Integer.parseInt(w4));
        ps4.setString(11,m5);
         ps4.setInt(12,Integer.parseInt(w5));
        ps4.setString(13,m6);
         ps4.setInt(14,Integer.parseInt(w6));
        ps4.setString(15,m7);
         ps4.setInt(16,Integer.parseInt(w7));
        ps4.setString(17,m8);
         ps4.setInt(18,Integer.parseInt(w8));
        ps4.setString(19,m9);
         ps4.setInt(20,Integer.parseInt(w9));
        ps4.setString(21,m10);
         ps4.setInt(22,Integer.parseInt(w10));


        ps4.executeQuery();
        //String p2=rs2.getString(1);

         }
         catch(Exception e)
         {
              System.out.println(""+e);
         }
    %>
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
        <!-- Let's welcome the user ${param.name} -->
        Hello ${param.name}!
    </c:if>
    --%>

    </body>
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.