2 messages in com.mysql.lists.javaException data truncation.| From | Sent On | Attachments |
|---|---|---|
| Abo Pignard | 01 Jul 2004 14:03 | |
| Mark Matthews | 02 Jul 2004 07:24 |
| Subject: | Exception data truncation.![]() |
|---|---|
| From: | Abo Pignard (abo....@wanadoo.fr) |
| Date: | 07/01/2004 02:03:50 PM |
| List: | com.mysql.lists.java |
Hello,
I use an MySQL 4.1.2 database with a field "annee" of type "year". I execute a Java query with the connector 3.1.2 : return stmt.executeUpdate( "insert into oeuvres (annee)" + " values (\"" + annee + "\");");
The Java variable "annee" is a String that may be empty. If so I get the exception : SQLException: Data truncation: Data truncated for column 'annee' at row 1 SQLState: 01004 VendorError: 0 Stack: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data truncated for column 'annee' at row 1 at com.mysql.jdbc.SQLError.convertShowWarningsToSQLWarnings(SQLError.java: 439) at com.mysql.jdbc.MysqlIO.scanForAndThrowDataTruncation(MysqlIO.java:3290) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1651) at com.mysql.jdbc.Connection.execSQL(Connection.java:2265) at com.mysql.jdbc.Connection.execSQL(Connection.java:2202) at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1235) at GestionBase.createOeuvres(GestionBase.java:214) at ... then the database is anyway updated with "2000" value.
Is it correct to get this Java exception and the database updated? Is there a mean to disable this exception in database configuration?
Thanks in advance for your answers.
Best regards, Pascal. http://perso.wanadoo.fr/blady




