while running my program as follows Register1.html
<!DOCTYPE html> <html lang="en"><head> <meta charset="utf-8"> <title>JavaScript Form Validation using a sample registration form</title> <meta name="keywords" content="example, JavaScript Form Validation, Sample registration form" /> <meta name="description" content="This document is an example of JavaScript Form Validation using a sample registration form. " /> <link rel='stylesheet' href='style.css' type='text/css' /> <script src="Validation.js"></script> </head> <body onload="document.registration.userid.focus();"> <form name='registration' action="regdat.jsp" onSubmit="return formValidation();"> <table border="1" align="center"> <tr align="center"> <div class="ab"> <td> <a href="E:\JE project\Home Page.html">Home</a></td>     <td><a href="E:\JE project\Register.html">Register</a> </td>     <td><a href="E:\JE project\Login.html">Login</a> </td> <td><a href="E:\JE project\About Us.html">About Us</a> </td>     <td><a href="E:\JE project\Contact Us.html">Contact Us</a></td>     <td><a href="E:\JE project\College Features.html">Features</a> </td>     <td><a href="E:\JE project\Gallery.html">Gallery</a> </td> </div> </tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> <tr></tr> </table> <h1 class="s1">Registration Form</h1> <table> <tr> <td class="s2">User id:</td> <td class ="s3"><input type="text" name="userid" size="12" /> </td> </tr> <tr> <td calss="s2">Password:</td> <td class="s3"><input type="password" name="passid" /></td> </tr> </table> <hr> <table> <h4 class="s4">PERSONAL DETAILS</h4> <tr><td class="s2">Name:</td> <td class="S3"><input type="text" name="username"/></td> </tr> <tr><td class="s2">DOB:</td> <td class="s3"><select name="dob" > <option selected =" " value="date">Date</option> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="dob" > <option selected="" value="month">Month</option> <option value="Janurary">Janurary</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <select name="dob" > <option selected="" value="year">Year</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1989">1989</option> <option value="1990">1990</option> <option value="1991">1991</option> <option value="1992">1992</option> <option value="1993">1993</option> </select> </tr> <tr><td class="s2">Nationality:</td> <td class="s3"><select name="nationality"> <option selected="" value="Default"></option> <option value="Indian">Indian</option> <option value="Others">Others</option> </td> </tr> <tr><td class="s2">Sex:</ltd> <td class="s3"><input type="radio" name="sex" value="Male" />Male</td> <td class="S3"><input type="radio" name="sex" value="Female" />Female</td> </tr> <tr><td class="s2">Address:</td> <td class="s3"><input type="textarea" name="address" rows="4" cols="10" /></td> </tr> <tr><td class="s2">ZIP Code:</td> <td class="s3"><input type="text" name="zip"/></td> </tr> <tr><td class="s2">State</td> <td class="s3"><Select id="Stat" name="country"> <option name="select" selected="true">Select</option> <option name="Andaman & Nicobar ">Andaman & Nicobar </option> <option name="Andhra Pradesh">Andhra Pradesh </option> <option name="Arunachal Pradesh">Arunachal Pradesh </option> <option name="Assam">Assam </option> <option name="Bihar">Bihar </option> <option name="Chhattisgarh">Chhattisgarh </option> <option name="Goa">Goa </option> <option name="Gujarat">Gujarat </option> <option name="Haryana">Haryana </option> <option name="Himachal Pradesh">Himachal Pradesh </option> <option name="Jammu & Kashmir">Jammu & Kashmir </option> <option name="Jharkhand">Jharkhand </option> <option name="Karnataka">Karnataka </option> <option name="Kerala">Kerala </option> <option name="Madhya Pradesh">Madhya Pradesh </option> <option name="Maharashtra">Maharashtra </option> <option name="Manipur">Manipur </option> <option name="Meghalaya">Meghalaya </option> <option name="Mizoram">Mizoram </option> <option name="Nagaland">Nagaland </option> <option name="Orissa">Orissa </option><option name="Punjab">Punjab </option> <option name="Rajasthan">Rajasthan </option> <option name="Sikkim">Sikkim </option> <option name="Tamil Nadu">Tamil Nadu </option> <option name="Tripura">Tripura </option> <option name="Uttar Pradesh">Uttar Pradesh </option> <option name="Uttaranchal">Uttaranchal </option> <option name="West Bengal">West Bengal </option> </select> </td> </tr> <tr><td class="s2">MobileNo.</td> <td class="s3"><input type="text" name="mobile" size="16"/></td> </tr> <tr><td class="s2">Email:</td> <td class="s3"><input type="text" name="email"/></td> </tr> </table> <hr> <h4> EDUCATION DETAILS</h4> <table border="1"> <tr> <th>Degree</th> <th>Institution Name</th> <th>Percentage</th> <th>YearofPassing</th> </tr> <tr> <td class="s2">SSLC</td> <td class="s3"><input type="text" name="XSchoolName"></td> <td class="s3"><select name="Xpercentage"> <option name="" selected="true"></option> <option value="<50"><50</option> <option value=">50">>50</option> <option value=">60">>60</option> <option value=">70">>70</option> <option value=">80">>80</option> <option value=">90">>90</option> </select> </td> <td class="s3"><input type="text" name="Xyop"></td> </tr> <tr> <td class="s2">HSC</td> <td class="s3"><input type="text" name="XIISchool Name"></td> <td class="s3"><select name="XIIpercentage"> <option name="" selected="true"></option> <option value="<50"><50</option> <option value=">50">>50</option> <option value=">60">>60</option> <option value=">70">>70</option> <option value=">80">>80</option> <option value=">90">>90</option> </select> </td> <td class="s3"><input type="text" name="XIIyop"></td> </tr> <tr> <td class="s2">UG</td> <td class="s3"><input type="text" name="UInstitutionName"></td> <td class="s3"><select name="Upercentage"> <option name="" selected="true"></option> <option value="<50"><50</option> <option value=">50">>50</option> <option value=">60">>60</option> <option value=">70">>70</option> <option value=">80">>80</option> <option value=">90">>90</option> </select> </td> <td class="s3"><input type="text" name="Uyop"></td> </tr> <tr> <td class="s2">PG</td> <td class="s3"><input type="text" name="PInstitutionName"></td> <td class="s3"><select name="Ppercentage"> <option name="" selected="true"></option> <option value="<50"><50</option> <option value=">50">>50</option> <option value=">60">>60</option> <option value=">70">>70</option> <option value=">80">>80</option> <option value=">90">>90</option> </select> </td> <td class="S3"><input type="text" name="Pyop"></td> </tr> </table> <table> <tr> <td><input type="submit" name="submit" value="Submit" /></td> </tr> </table> </form> </body> </html>
redata.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page import="java.sql.*" %> <%@ page import="java.io.*" %>Â <html> <head> <title>Connection with mysql database</title> </head> <body> <h1>Connection status</h1> <% String userid=request.getParameter("userid"); String passid=request.getParameter("passid"); String username=request.getParameter("username"); String dob=request.getParameter("dob"); String nationality=request.getParameter("nationality"); String sex=request.getParameter("sex"); String address=request.getParameter("address"); String zip=request.getParameter("zip"); String country=request.getParameter("country"); String mobile=request.getParameter("mobile"); String email=request.getParameter("email"); String instution=request.getParameter("instution"); String XSchoolName=request.getParameter("XSchoolName"); String Xpercentage=request.getParameter(" Xpercentage"); String Xyop=request.getParameter("Xyop"); String XIISchoolName=request.getParameter("XIISchoolName"); String XIIpercentage=request.getParameter("XIIpercentage"); String XIIyop=request.getParameter("XIIyop"); String UInstutionName=request.getParameter("UInstutionName"); String Upercentage=request.getParameter("Upercentage"); String Uyop=request.getParameter("Uyop"); String PInstutionName=request.getParameter("PInstutionName"); String Ppercentage=request.getParameter("Ppercentage"); String Pyop=request.getParameter("Pyop"); try { String connectionURL = "jdbc:mysql://localhost:3306/stu"; // declare a connection by using Connection interface Connection connection = null; //Â Load JBBC driver "com.mysql.jdbc.Driver" Class.forName("com.mysql.jdbc.Driver").newInstance(); /* Create a connection by using getConnection() method that takes parameters of string type connection url, user name and password to connect to database. */ connection = DriverManager.getConnection(connectionURL, "root", ""); // check weather connection is established or not by isClosed() method if(!connection.isClosed()) %> <% out.println("successsfully connected"); ResultSet rs = null; PreparedStatement ps; ps = connection.prepareStatement("INSERT INTO candP (userid,passid,username,dob,nationality,sex,address,zip,country,mobile,email,instution,XSchoolName,Xpercentage,Xyop,XIISchoolName,XIIpercentage,XIIyop,UInstutionName,Upercentage,Uyop,PInstutionName,Ppercentage,Pyop) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); ps.setString(1,userid); ps.setString(2,passid); ps.setString(3,username); ps.setString(4,dob); ps.setString(5,nationality); ps.setString(6,sex); ps.setString(7,address); ps.setString(8,zip); ps.setString(9,country); ps.setString(10,mobile); ps.setString(11,email); ps.setString(12,instution); ps.setString(13,XSchoolName); ps.setString(14,Xpercentage); ps.setString(15,Xyop); ps.setString(16,XIISchoolName); ps.setString(17,XIIpercentage); ps.setString(18,XIIyop); ps.setString(19,UInstutionName); ps.setString(20,Upercentage); ps.setString(21,Uyop); ps.setString(22,PInstutionName); ps.setString(23,Ppercentage); ps.setString(24,Pyop); int i = ps.executeUpdate(); out.println("Welcome"); out.println(i); if(i!=0) { out.println("your Data has been successfully stored in database"); out.println("Hello"+username); } else { out.println("Try again"); } } catch(Exception ex) { ex.printStackTrace(response.getWriter()); out.println("unable to connect database"); } %> </body> </html>
while running this program in tomcat server i got the following exception:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value for column 'zip' at row 1 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2983) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3283) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1604) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1519) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1504) at org.apache.jsp.regdatjsp.jspService(regdat_jsp.java:138) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:600) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1703) at java.lang.Thread.run(Thread.java:662)
Connection status
successsfully connected unable to connect database
Pls say whts wrong??? thanks in advance
Ads