Data Truncation Incorrect Date Value

Try reformating the date. String date = new SimpleDateFormat('yyyy-MM-dd').format(new Date(request.getParameter('date'))); and then insert into the database. Note that request.getParameter('date') should be in format for this to. If you want to make the DATE column mandatory in the following table: CREATE TABLE `altastalleres` ( `id` INT(10) NOT NULL AUTOINCREMENT, `fecha` DATE NULL, `socioid` INT(10) NOT NULL, PRIMARY KEY (`id`), INDEX `FKaltastalleressocios` (`socioid`), CONSTRAINT `FKaltastalleressocios` FORE.

  • Incorrect date value: ' for column 'dataapertura' at row 1. What have i to change? (i tried to change format's date from gg/mm/yyyy to gg-mm-yyyy, but.
  • ERROR 1292 (22007): Truncated incorrect date value: ' 00:00:00' alter table UyeUyeListe modify DogumTarihi datetime; ERROR 1292 (22007): Incorrect datetime value: ' for column 'DogumTarihi' at row 2.
Ranch Hand
posted 2 years ago
Hi guys,
more one problem for yours. I have this DAO that I want to return the code of an item, the return are ok but the problem is that when I get the code returned to write in my db, the message is data too long.
My DAO:

And this is my access:

The line 28 is to know the code returned, this is the result of the disply:
Codigo antes de gravar: [Bean_Procedimentos_Ultra{CNES=null, Procedimentos=null, Codigo=004}, Bean_Procedimentos_Ultra{CNES=null, Procedimentos=null, Codigo=004}]
My problem is that I can´t access the 'Codigo'.
Can you help me?
Thanks in advance.
Cezar Apulchro.
Rancher
posted 2 years ago
I think we need a bit more information.
What is the full error you are getting, and where is it occurring?
Do you know the value that is giving that error?
If the value is incorrect, what should the value be?
Saloon Keeper
posted 2 years ago
Also post the description (column names and types) of the Tabela_Procedimentos_Ultrassonografia table.
Rancher
posted 2 years ago
Set column dataType to LONGTEXT should fix the issue.
Ranch Hand
posted 2 years ago
Hi Tim,
thank you for assistance.
This is my table:

This is the content of my table:

And the full error:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'Codigo_Procedimentos' at row 1
The error occur in line 31(pcdao.cadastrarUltrassonografia(dpaciente);) I believe caused by line 29(dpaciente.setCodigo_Procedimento(codprocedimentos);).
The result of this dysplay:

Is:
Codigo antes de gravar: [Bean_Procedimentos_Ultra{CNES=null, Procedimentos=null, Codigo=004}, Bean_Procedimentos_Ultra{CNES=null, Procedimentos=null, Codigo=004}]
CNES, Procedimentos and Codigo, are columns of my table and of my Bean. Note in this dysplay Codigo=004, the content of Codigo are ok, my problem is that I can't access this content in return of my Select.
Thanks.
Saloon Keeper
posted 2 years ago
It's extra challenging when not only the object, property and method names are not in English, but so are the error messages!
It appears that you have a fault in your registration method (cadastrarUltrassonografia), but unless I'm just blind today, you didn't show us what the PacientesDAO_W01 class that defines it looks like, so we have no idea what it's expecting.
The error message looks possibly like you have 2 patient records in it, and you're attempting to force them into a single database field - multiple columns AND multiple rows!
But that is only my best attempt at divination.

Some people, when well-known sources tell them that fire will burn them, don't put their hands in the fire.
Some people, being skeptical, will put their hands in the fire, get burned, and learn not to put their hands in the fire.
And some people, believing that they know better than well-known sources, will claim it's a lie, put their hands in the fire, and continue to scream it's a lie even as their hands burn down to charred stumps.

Rancher
Data truncation incorrect date valueposted 2 years ago
Data too long for column 'Codigo_Procedimentos'
That is not a column of the table you posted.
It looks like this is an error (as Tim says) from another method, not the one you have already posted.
From the stack trace is would be the cadastrarUltrassonografia method.
Ranch Hand
posted 2 years ago

Mysqldatatruncation Data Truncation Incorrect Date Value

Hi Dave,
this is my method cadastrarUltrassonografia:

And this is piece of my bean:

My bean is very long.
Thanks.
Rancher
posted 2 years ago

Now, based on your first post, the value being used here is:
'
[Bean_Procedimentos_Ultra{CNES=null, Procedimentos=null, Codigo=004}, Bean_Procedimentos_Ultra{CNES=null, Procedimentos=null, Codigo=004}]
'
which has come from using the codprocedimentos String in the call to setCodigo_Procedimento.
And that String comes from:

And lbultra is a List.
So, the question is, what exactly is supposed to be supplied to setCodigo_Procedimento?
What is it you actually want to go in there?
If it is (as it sounds like) the value of Codigo from that String, then which Codigo, as there are two (which happen to be the same in this example).
Ranch Hand
posted 2 years ago
Dave I don't understand what you mean, I have an table with 3 collumns, I use only collumn 'Procedimentos' to populate a box to user choice in my jsp page. I get the user option and I want to get the code 'Codigo' of that option in my table. I have constructed another method but the problem still the same.

This method was constructed first, but has same problem, then I cosntructed the 'lstCodUltra' method.
Thanks.
Greenhorn
posted 2 years ago
I think you need to increase the size of your table column.
Saloon Keeper
posted 2 years ago
You are leaking resources. If you get a SQLException, it causes the PreparedStatement.close() method to be bypassed.
What it looks like is that instead of sending the value of the Codigo_Procedimento - which appears to be a class instance, not a simple value - to the SQL preparer you are sending the value of the Codigo_Procedimento.toString() method, which is much longer than the actual data value, since it contains additional information about the Codigo_Procedimento which appears to be not a single value, but an entire class.
SQL isn't designed to stuff multiple objects into a single column. So you have to select an alternative:
1. Put the data into multiple columns, one column per data element
2. Encode the data into a single value (for example a String or serialized Java) and store it into a column large enough to hold it.
3. Write the data into a separate and distinct table and have your primary data reference that data (via a foreign key).
What it looks like you are attempting is option 2 but without a large enough column. Aside from needing enough space to hold the data, you'd also need a corresponding decode (deserialize) operation when you read the data back. And while I mentioned Java serialization as an alternate format, I don't recommend using it, because different JVM versions do it differently so you might not be able to deserialize it later.

Some people, when well-known sources tell them that fire will burn them, don't put their hands in the fire. Purin to ohuro. What two metals are scuba tanks commonly made from.
Some people, being skeptical, will put their hands in the fire, get burned, and learn not to put their hands in the fire.
And some people, believing that they know better than well-known sources, will claim it's a lie, put their hands in the fire, and continue to scream it's a lie even as their hands burn down to charred stumps.

Rancher
posted 2 years ago
  • 1

How to reset dji spark wifi password. Cezar Apulchro wrote:Dave I don't understand what you mean..

Com.mysql.jdbc.mysqldatatruncation Data Truncation Incorrect Date Value


OK.
According to your second post above you are getting the error:
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'Codigo_Procedimentos' at row 1
Column That highlighted name is the column causing the issue.
That column is populated by the PreparedStatement code you posted just above here.
And this is the line that does that:
Data Truncation Incorrect Date Value
So your problem is that the value supplied there (which, if we work back up the code, comes from that toString call) is incorrect.
I am trying to find out what it should be.
Ranch Hand
posted 2 years ago
Hi guys,
I solved my problem 'Data truncation: Data too long for column'.
Solution:
in mysql table: codigo varchar changed to int
in bean: I changed String to int

thanks a lot everybody.
Cezar.