Home Answers Viewqa SQL MYSQL EXCEPTION -DATA TRUNCATION..pls resolve it

 
 


REKHA
MYSQL EXCEPTION -DATA TRUNCATION..pls resolve it
0 Answer(s)      6 months and 22 days ago
Posted in : SQL

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









Related Pages:
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
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
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
How to resolve NumberFormatException(Unlnown Source)?
How to resolve NumberFormatException(Unlnown Source)?  I'm using some... the exception. Code i'm is some thing like that:`print("<% String t...=Integer.parseInt(t); out.println(t1); } catch(Exception e){ out.println(e); } %>
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
exception
exception  Identify the reason for SQLException exception, which..."); Connection con = DriverManager.getConnection("jdbc:mysql://localhost..."); ps.executeUpdate(); } catch(Exception e
throw exception in mysql trigger
throw exception in mysql trigger  throw exception in mysql trigger
Can anybody tell me how to resolve this issue?
Can anybody tell me how to resolve this issue?  java.lang.Exception: Exception : java.lang.Exception: Generic Errors = java.util.MissingResourceException: Can't find bundle for base name Connection, locale en_US
MySQL exception - Development process
MySQL exception  HI.. how to prevent this exception com.mysql.jdbc.exceptions.mysqlnontransientconnectionexception pz tell me the query
error occured in following page ... how to resolve it?
error occured in following page ... how to resolve it?  // to convert image into thumbnail i used following code. But netbeans has given me following....... error is:::: Exception in thread "main" java.lang.IllegalArgumentException
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 handling
Exception handling  how to resolve file not found error exception
Exception: com.mysql.jdbc.Driver
Exception: com.mysql.jdbc.Driver  How to resolve Exception: com.mysql.jdbc.Driver in netbeans? Thanks in advance
How to resolve this error The filename, directory name, or volume label syntax is incorrect
How to resolve this error The filename, directory name, or volume label syntax...() throws Exception { ................... } public void randomImage(String uname) throws Exception { ..................... Robot robot = new Robot
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
get ting this Exception - EJB
get ting this Exception  Root exception is javax.naming.NameNotFoundException: Unable to resolve 'PTASessionBean'. Resolved '']; remaining name 'PTASessionBean
Hibernate giving exception - struts - MySQL - Hibernate
Hibernate giving exception - struts - MySQL  Hi all, My name..., and using Struts frame work with hibernate and MySQL database. I am getting exection... com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/sampledb
Jfree exception
void main(String arg[])throws Exception{ Class.forName...:mysql://localhost:3306/test", "root", "123" ); Statement st.......... Exception in thread "main" java.lang.ClassNotFoundException
Jfree exception
void main(String arg[])throws Exception{ Class.forName...:mysql://localhost:3306/test", "root", "123" ); Statement st.......... Exception in thread "main" java.lang.ClassNotFoundException
bean creation exception
to resolve the above exception   The server is trying to load this file...bean creation exception  hi i am getting exception while running simple spring ioc program Exception in thread "main
how to use mysql event scheduler in hibernate
("); it gives native batch update Exception How can resolve this problem can...how to use mysql event scheduler in hibernate  Hi all, I am creating... of time, i need to use mysql event scheduler My query is like this create event
Exception - JSP-Servlet
IllegalStateException: getOutputStream() has already called for this response.. How to resolve
exception at runtime - JDBC
to correct this problem.i am using mysql-essential-5.0.41-win32_1. pls help...exception at runtime  while i executing this source code:- import...[]) { System.out.println("MySQL Connect Example."); Connection con = null
exception error inservlet
exception error inservlet  Hi,i got the error as..below..wat could be the possible mistake ?THANK YOU!!! type Exception report message description... this request. exception javax.servlet.ServletException: JDBC Driver not found
java runtime exception - JDBC
(String args[]) { System.out.println("MySQL Connect Example."); Connection con = null; String url = "jdbc:mysql://localhost:3306..."); } catch (Exception e) { e.printStackTrace
jdbc adapter exception - JDBC
jdbc adapter exception  Through JDBC, I connected to MySQL Server... in MySQL through my Java Application. For that I added "?sessionVariables = FOREIGN_KEY_CHECKS = 0" to JDBC URL( i.e., "jdbc:mysql://MyHost/myDB").Modified URL
exception
exception  wHEN RUNTIME EXCEPTION CLASS IS SUB OF EXCEPTION CLASS HOW CAN'T HANDLE UNCHECKED EXCEPTION
exception
exception  chek in and check out exception in java   Please visit the following link: Checked and Unchecked Exception
Reflection api :Invocation target exception - JDBC
it,but it throws a class not found : oracle.jdbc.driver.oracledriver exception in Invocation target Exception .How to resolve...Reflection api :Invocation target exception   Am using a function
Exception - JSP-Servlet
Exception  I m executing the jsp code to upload file n store in mysql database. It is working fine for text file but the same program if i do with doc file its gives java.lang.StringIndexOutOfBoundException: String index out
Hibernate nullpointer exception - Hibernate
Hibernate nullpointer exception  Hi, I am using eclipse IDE.I copied hibernate example from roseindia.net. I am using MYSQL as my database. 1.In eclipse I hava created new javaproject. 2.I hava copied Contact.java. and I
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
exception  example for numberformat exception   Hi Friend, Try the following code: class NumberFormatExceptionEx{ public static void...); } catch(Exception e){ System.out.println(e
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
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
NullPointer Exception - JSP-Servlet
NullPointer Exception  It is in jsp - mysql database program. In this pro. it enters into the statement before try statement. It does not enter into the try statement. I found this by checking out.println("test"); statement
Java and Mysql
Java and Mysql  Sir, I want to connect my java program with mysql server (mysql server is situated on another windows machine ) ??? ???? ?????   Put mysql jar file in your jdk lib and set the classpath. After
netbeans with mysql and tomcat
netbeans with mysql and tomcat  Hi. I have to run a JSP or JAVA file in netbeans with mysql database and tomcat server 7.0. But while the page... to resolve it. Thanks in advance
Servlet.init() for servlet FacesServlet threw exception
Servlet.init() for servlet FacesServlet threw exception  javax.servlet.ServletException: Servlet.init() for servlet FacesServlet threw exception...(Thread.java:662) Please let me know how to resolve the above issue..when i
JDBC Exception
JDBC Exception       The Exception are the set of condition that occurred when an abnormal... the execution of program. Exception Occurred in JDBC Connectivity when a connection

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.