I have a MySQL table with three fields:
fname varchar(20)
ftype varchar(10)
value varchar(30)
as you can see "value" is a varchar, but I use it to store differente kind of value (entered by users), so I can do:
UPDATE table SET value = 1 + value WHERE ftype='COUNTER';
it works as intended, doing an implicit conversion and then update and store, so:
fname ftype value
f1 COUNTER 100
f2 COUNTER 100 dǵ#$vferv <-- this value contains an input error
become:
fname ftype value
f1 COUNTER 101
f2 COUNTER 101
I'm perfectly fine with it.
The point is that if I execute the query directly, it works (and eventually MySQL return some warnings if I run show warnings
), but if I run in inside a Java EE app (running under glassfish) those warnings are treated like errors so I'll get an exception (ie: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '100 dǵ#$vferv'
).
Is there any option in the JDBC driver to tell it not throw exception in this case?