如何把控制台输出的完整错误信息保存到文本?
本帖最后由 u013558606 于 2014-04-01 09:26:20 编辑
控制台输出的错误信息
[INFO ] [09:10:08] org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl - HHH000010: On release of batch it still contained JDBC statements
[WARN ] [09:10:08] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 23505
[ERROR] [09:10:08] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - 批次处理 0 insert into cattagb_page (btname, burl, bvid, commentnums, curl, imgpath, jianjie, paiming, popularity, productnums, supercurlkey, turl, userdislike, usergrade, userlike, tburl) values ('....') 被中止,呼叫 getNextException 以取得原因。
[WARN ] [09:10:08] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: 23505
[ERROR] [09:10:08] org.hibernate.engine.jdbc.spi.SqlExceptionHelper - 错误: 重复键违反唯一约束"uk_ex9kef7svstkgntmfy2vh5emn"
详细:键值"(turl, burl)=(laVjN, ChsfT)" 已经存在
[ERROR] [09:10:08] org.hibernate.engine.jdbc.batch.internal.BatchingBatch - HHH000315: Exception executing batch [could not execute batch]
org.hibernate.exception.ConstraintViolationException: could not execute batch
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:129)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:132)
at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.doExecuteBatch(BatchingBatch.java:111)
at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.execute(AbstractBatchImpl.java:163)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.getBatch(JdbcCoordinatorImpl.java:206)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3102)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3587)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:103)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:453)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:345)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1218)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:421)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
at zyme.tools.hibernate.MyHibernateUtil.oneThreadCheckThanSaveAllUpgraded(MyHibernateUtil.java:244)
at threads.save.SaveThread.savebegin(SaveThread.java:37)
at threads.save.SaveThread.run(SaveThread.java:31)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.sql.BatchUpdateException: 批次处理 0 insert into cattagb_page (btname, burl, bvid, commentnums, curl, imgpath, jianjie, paiming, popularity, productnums, supercurlkey, turl, userdislike, usergrade, userlike, tburl) values ('....') 被中止,呼叫 getNextException 以取得原因。
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2762)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1891)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:405)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2909)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1135)
at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:123)
... 18 more
报错的时候通过下面的代码保存的错误信息到文本.
catch (Exception e)
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try{
e.printStackTrace(new PrintStream(baos));
}finally{
try {
baos.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}