MYSQL EXCEPTION -DATA TRUNCATION..pls resolve it

Ads
 

MYSQL EXCEPTION -DATA TRUNCATION..pls resolve it

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>
&nbsp
&nbsp
<td><a href="E:\JE project\Register.html">Register</a> </td>
&nbsp
&nbsp
<td><a href="E:\JE project\Login.html">Login</a> </td>
<td><a href="E:\JE project\About Us.html">About Us</a> </td>
&nbsp
&nbsp

<td><a href="E:\JE project\Contact Us.html">Contact Us</a></td>
&nbsp
&nbsp
<td><a href="E:\JE project\College Features.html">Features</a> </td>
&nbsp
&nbsp

<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>
&nbsp;
&nbsp;
<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>
&nbsp;
&nbsp;
<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>
&nbsp;
&nbsp;
<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="&lt50">&lt50</option>
<option value="&gt50">&gt50</option>
<option value="&gt60">&gt60</option>
<option value="&gt70">&gt70</option>
<option value="&gt80">&gt80</option>
<option value="&gt90">&gt90</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="&lt50">&lt50</option>
<option value="&gt50">&gt50</option>
<option value="&gt60">&gt60</option>
<option value="&gt70">&gt70</option>
<option value="&gt80">&gt80</option>
<option value="&gt90">&gt90</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="&lt50">&lt50</option>
<option value="&gt50">&gt50</option>
<option value="&gt60">&gt60</option>
<option value="&gt70">&gt70</option>
<option value="&gt80">&gt80</option>
<option value="&gt90">&gt90</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="&lt50">&lt50</option>
<option value="&gt50">&gt50</option>
<option value="&gt60">&gt60</option>
<option value="&gt70">&gt70</option>
<option value="&gt80">&gt80</option>
<option value="&gt90">&gt90</option>
</select>
</td>
<td class="S3"><input type="text" name="Pyop"></td>
</tr>
</table>

&nbsp;
&nbsp;
&nbsp;
&nbsp;
<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

View Answers

Ads









Related Tutorials/Questions & Answers:
throw exception in mysql trigger
throw exception in mysql trigger  throw exception in mysql trigger
my hibernate showing the following exception so how i can resolve it
my hibernate showing the following exception so how i can resolve it   Caused by: java.lang.ClassNotFoundException: org.hibernate.Session at java.net.URLClassLoader$1.run(Unknown Source
Advertisements
How do I resolve this Java Class not found exception?
How do I resolve this Java Class not found exception?  Hi, Many time new developer faces the Class not found exception. Why it happens and how to resolve this? Thanks   Hi, The main reason of this exception is un
try to execute this code getting class cast exception, please resolve it.
try to execute this code getting class cast exception, please resolve it.  package test; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; public class Over { static int k
Getting Exception on UseDefinedException sample program - Please help me how to resolve
Getting Exception on UseDefinedException sample program - Please help me how to resolve  class UseDefinedException extends Exception{ String msg...); } } } Hi, I tried above code but getting Exception : MyException cannot
what are the jar files should i add to resolve the Exception(Class org.apache.jsp.index_jsp Not Found) ?
what are the jar files should i add to resolve the Exception(Class... to resolve the following Exception HTTP Status 500 - type Exception report... it from fulfilling this request. exception javax.servlet.ServletException: Wrapper
exception
exception  wHEN RUNTIME EXCEPTION CLASS IS SUB OF EXCEPTION CLASS HOW CAN'T HANDLE UNCHECKED EXCEPTION
exception
exception  Identify the reason for SQLException exception, which..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost..."); ps.executeUpdate(); } catch(Exception e
exception
exception  chek in and check out exception in java   Please visit the following link: Checked and Unchecked Exception
exception
arguments are not equalto two,throw a user defined exception "invalid parameter exception" ,otherwise display the two parameters.   Here is an example... is not equal to two then invalid parameter exception is thrown ,otherwise display the two
exception
exception  what is the use of catch block even though we have predefined exception object
exception
defined checked exception √Ę‚?¨Ň?InvalidCharcterFoundException√Ę‚?¨¬? and creater a block of codes that will handle the exception
Exception
Exception  whis is the Arithmetic Exception in java? or define Arithmetic Exception with exp?   Arithmetic Exception occurs, when you divide a number by zero. Example public class TryCatch { public static void main
Exception
Exception  public class FooException extends Exception { public..."); } public void calculate() throws FooException, Exception { try { int.... ex.printStackTrace(); System.exit(1); } catch(Exception ex
Exception
Exception   I was creating a table dynamically but it shows exception i.e shown down Suplier created0 Suplier created0 Suplier created0 Product created0 Product created0 Product created0 Product created0 could not fetch initial
Exception: com.mysql.jdbc.Driver
Exception: com.mysql.jdbc.Driver  How to resolve Exception: com.mysql.jdbc.Driver in netbeans? Thanks in advance
exception
user defined unchecked exception  can we create user defined unchecked exceptions? if so what is the exact use of it in real time?   Please visit the following links: http://www.roseindia.net/java/java-exception/user
ModuleNotFoundError: No module named 'resolve'
ModuleNotFoundError: No module named 'resolve'  Hi, My Python... 'resolve' How to remove the ModuleNotFoundError: No module named 'resolve... to install padas library. You can install resolve python with following command
how to resolve this JDBC Error?
how to resolve this JDBC Error?  i am trying to Exceute this code: import java.sql.DatabaseMetaData; import java.sql.Connection; import... but when i am executing this code i am getting this Error: Exception in thread
get ting this Exception - EJB
get ting this Exception  Root exception is javax.naming.NameNotFoundException: Unable to resolve 'PTASessionBean'. Resolved '']; remaining name 'PTASessionBean
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'  Hi...: No module named 'fsqio.pants.pom-resolve' How to remove the ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve' error? Thanks   
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'  Hi...: No module named 'fsqio.pants.pom-resolve' How to remove the ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve' error? Thanks   
ModuleNotFoundError: No module named 'resolve_link'
ModuleNotFoundError: No module named 'resolve_link'  Hi, My Python... 'resolve_link' How to remove the ModuleNotFoundError: No module named 'resolve_link' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'  Hi...: No module named 'fsqio.pants.pom-resolve' How to remove the ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve' error? Thanks   
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'
ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve'  Hi...: No module named 'fsqio.pants.pom-resolve' How to remove the ModuleNotFoundError: No module named 'fsqio.pants.pom-resolve' error? Thanks   
ModuleNotFoundError: No module named 'import_resolve'
ModuleNotFoundError: No module named 'import_resolve'  Hi, My... named 'import_resolve' How to remove the ModuleNotFoundError: No module named 'import_resolve' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'resolve-target'
ModuleNotFoundError: No module named 'resolve-target'  Hi, My... named 'resolve-target' How to remove the ModuleNotFoundError: No module named 'resolve-target' error? Thanks   Hi, In your python
Exception in Thread
Exception in Thread    i am developing a rmi application in eclipse... client and generate connection with server i have following exception : Blockquote Exception in thread "RMI TCP Connection(idle
MYSQL
MYSQL  How to create time and date based trigger in mysql   MySQL Time Trigger
mysql
mysql  how to open\import table in .dbf format in mysql
exception handling
exception handling  explain about exception handling

Ads