Bug #110943 unable to insertjava.sql.SQLException: Data truncated for column 'HIREDATE' at r
Submitted: 7 May 2023 6:31 Modified: 8 May 2023 7:59
Reporter: prasanna kumar Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[7 May 2023 6:31] prasanna kumar
Description:
 System.out.println("Enter at what date will you return the book in (dd/MM/yyyy) ?");
	           String sReturnDate=sc.nextLine();
	           int d1=0,d2=0;
	   	    if (sHireDate.charAt(0)=='0')
	   	    {
	   	         d1=Character.getNumericValue(sHireDate.charAt(1));
	   	        
	   	    }
	   	    else{
	   	         d1=Integer.valueOf(sHireDate.substring(0,2));
	   	    }
	   	  if (sReturnDate.charAt(0)=='0')
	   	    {
	   	         d2=Character.getNumericValue(sReturnDate.charAt(1));
	   	        
	   	    }
	   	    else{
	   	         d2=Integer.valueOf(sReturnDate.substring(0,2));
	   	    }
	   	  int netD=d2-d1;
	   	  int totalHirePrice=netD*hp;
	  	Hire h=new Hire(hid,cId,aid,sHireDate,sReturnDate,status,totalHirePrice);
		result=HireDAO.insertHire(h);
		if(result!=0)
		{
			System.out.println("Rental details inserted successfully");
		}
		else
		{
			System.out.println("Failed to insert");
		}  
		case 3:

How to repeat:
please help me how to resolve this when i am entering date  in console showing exception
[7 May 2023 6:34] prasanna kumar
create table HIRE(HIREID INT NOT NULL primary key,
CUSTOMERID INT,ALBUMID INT,
HIREDATE INT,RETURNDATE INT,STATUS varchar(100),
TOTAL_HIRE_PRICE INT,FOREIGN KEY(CUSTOMERID) REFERENCES USER(CUSTOMERID),
FOREIGN KEY(ALBUMID) REFERENCES ALBUMDETAILS(ALBUMID));  

i created this table
[8 May 2023 7:59] MySQL Verification Team
Hello Prasanna Kumar,

Thank you for writing us, but this is not a bug. 
Please change the datatype of HIREDATE and RETURNDATE to DATE or DATETIME and try again. Thanks.

Regards,
Ashwini Patil