Home > database >  How to prohibit MySQL5.7 thrown similar content is too long automatic truncation, int field automati
How to prohibit MySQL5.7 thrown similar content is too long automatic truncation, int field automati

Time:10-08

Similar content is too long "automatic truncation," "int field empty string automatically converted to 0", and other functions, the feeling is very convenient
My. Ini added sql_mode=NO_AUTO_CREATE_USER NO_ENGINE_SUBSTITUTION,
Just these two abnormal level by "Error" turned into "Warning", but still will throw an exception
I need these functions, but using Java program can always capture the two abnormal, I don't want the function throws an exception
1366 Incorrect integer value: 'for column' b 'at row 1
1265 Data truncated for column 'c' at row 1
Because, in the Java exception handler, can roll back the transaction, cause data cannot insert or update
General exception handling:
The catch (SQLException e) {//don't you want to capture here similar functions to the two abnormal
.
Con. The rollback ();//catch exceptions to these two, cause data can't insert update
.
}

CodePudding user response:

Do these things in the code, this is how lazy,,,

CodePudding user response:

Mysql have corresponding "switch" parameters, simple it is ok to set? If it is to write Java code, I need to change to involve more than N
  • Related