Can sometimes normal execution by, sometimes throw SQLException exceptions, the feeling is very strange, exception information is also very strange code roughly as follows:
Private void BatchInsertData (List
Try {
PrepareStatement ps=connection. PrepareStatement (" insert into A (A_ID, A_NAME, A_ENGLISH_NAME A_ADDERSS, A_PHONE_NUMBER) VALUES (1 A_SEQUENCE NEXTVAL,? ,? ,? ,?) ");
List. The forEach (beanClass - & gt; {
If (beanClss getName ()==null) {
Ps. SetNull (1, Types. VARCHAR);
} else {
Ps. SetString (1, beanClss getName ())
}
If (beanClss getEnglishName ()==null) {
Ps. SetNull (2 Types. VARCHAR);
} else {
Ps. SetString (2, beanClss getEnglishName ())
}
.
.
Ps. The addBatch ();//add batch
})
Ps. ExecuteBatch ();//perform batch
Conn.com MIT ();
} the catch (SQLException e) {
Conn. The rollback ();
System. Err. Println (the String. Format (" SQLException: Message [% s]; SQLState [% s]; ErrorCode [% s], "um participant etMessage (), um participant etSQLState (), um participant etErrorCode ()));
} the finally {
If (ps!=null) {
Ps. The close ();
}
}
}
}
The output of the anomaly information:
SQLException: Message (Error); SQLState (null), ErrorCode [0]
O great god answer