473,320 Members | 2,122 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

MYSQLDataTrunction: Data trunction: Incorrect date value 'y' for column 'xxxx' at ro1

2
I got the above error on the following code: Please help me.
Expand|Select|Wrap|Line Numbers
  1. public void setCheckinDate(int reservationNumber)
  2.     throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
  3.        {      
  4.             Class.forName("com.mysql.jdbc.Driver").newInstance();         
  5.             Connection con=DriverManager.getConnection("jdbc:mysql://localhost/hrs","root","esubalew");
  6.             Statement st=con.createStatement();
  7.             Scanner in=new Scanner(System.in);
  8.             int year, month, day;
  9.             System.out.println("  Enter Checkin date(YYYY, MM, DD)");
  10.             System.out.println("======================================");
  11.  
  12.             year=in.nextInt();
  13.             month=in.nextInt();
  14.             day=in.nextInt();
  15.             Date checkindate=new Date(year,month,day);
  16.  
  17.             String update="update reservation set chckinDate="+checkindate+" where ReservNumber="+reservationNumber;
  18.             st.executeUpdate(update);            
  19.             con.close();
  20.     }
the error is at the bold line. Date class is user defined. It works in other part of the program.
Oct 23 '07 #1
3 1888
esu
2
The problem was at the following line. look it carafully.
String update="update reservation set chckinDate='"+checkindate+" 'where ReservNumber="+reservationNumber;

Thank you, anyway!
Oct 23 '07 #2
code green
1,726 Expert 1GB
Looks like checkindate is an object, not a variable.
Expand|Select|Wrap|Line Numbers
  1. Date checkindate=new Date(year,month,day);
So failing here
Expand|Select|Wrap|Line Numbers
  1. update="update reservation set chckinDate="+checkindate+" 
But I am not sure about the Date class.
Oct 24 '07 #3
r035198x
13,262 8TB
I got the above error on the following code: Please help me.
Expand|Select|Wrap|Line Numbers
  1. public void setCheckinDate(int reservationNumber)
  2.     throws SQLException, ClassNotFoundException, InstantiationException, IllegalAccessException
  3.        {      
  4.             Class.forName("com.mysql.jdbc.Driver").newInstance();         
  5.             Connection con=DriverManager.getConnection("jdbc:mysql://localhost/hrs","root","esubalew");
  6.             Statement st=con.createStatement();
  7.             Scanner in=new Scanner(System.in);
  8.             int year, month, day;
  9.             System.out.println("  Enter Checkin date(YYYY, MM, DD)");
  10.             System.out.println("======================================");
  11.  
  12.             year=in.nextInt();
  13.             month=in.nextInt();
  14.             day=in.nextInt();
  15.             Date checkindate=new Date(year,month,day);
  16.  
  17.             String update="update reservation set chckinDate="+checkindate+" where ReservNumber="+reservationNumber;
  18.             st.executeUpdate(update);            
  19.             con.close();
  20.     }
the error is at the bold line. Date class is user defined. It works in other part of the program.
Why are you using a user defined Date class?
What is the type of chckinDate in the database?
Oct 24 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mark | last post by:
good spam subject ;). anyway, i'm alittle stumped. i'm in need of putting together a query that gets the next highest salary ( select max ( sal ) - 1?, from an emp_sal type table. another...
4
by: Justin Lebar | last post by:
Sorry about the huge post, but I think this is the amount of information necessary for someone to help me with a good answer. I'm writing a statistical analysis program in ASP.net and MSSQL7 that...
4
by: theintrepidfox | last post by:
Dear Group Some but not all of the dates are incorrect converted (incremented by 1 day) with the following SQL statement. SELECT DISTINCT CONVERT(datetime,cast(ReturnedByDate AS int)) AS...
4
by: bobdedogh | last post by:
can anyone add live hyperlinks to the sortable table made by the code supplied by Machi, or know of a simple alternative bob Machi wrote Mar 10 1999, 8:00 am >>>>>>>>>>>>>> .... Hello...
2
by: Dnna | last post by:
I have a table which is bound to an Internet Explorer XML data island. I'm using ASP.NET's client-side validators for an input field in the table. The problem is that if the input fields are in...
4
by: Nalaka | last post by:
Hi, I have two questions about gridViews. 1. How can I intercept the row/column values at loading to change values? 2. After I update a row (using default update functionality), how can I...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
10
by: pbd22 | last post by:
Hi. Like the title says - how do i do this? I was given the following example: INSERT INTO TABLE2 SELECT * FROM TABLE1 WHERE COL1 = 'A' The above statement threw the following error:
9
by: LucasLondon | last post by:
Hi, Sorry, this is a bit of a lengthy one but I guess too much information is better than less! I have an excel worksheet that I update regulary with latest values from downloaded CSV files....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.