当前位置: 首页>>代码示例>>Java>>正文


Java BatchUpdateException.getNextException方法代码示例

本文整理汇总了Java中java.sql.BatchUpdateException.getNextException方法的典型用法代码示例。如果您正苦于以下问题:Java BatchUpdateException.getNextException方法的具体用法?Java BatchUpdateException.getNextException怎么用?Java BatchUpdateException.getNextException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.BatchUpdateException的用法示例。


在下文中一共展示了BatchUpdateException.getNextException方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tratarHibernatePostgreSQL

import java.sql.BatchUpdateException; //导入方法依赖的package包/类
@ExceptionHandler
public void tratarHibernatePostgreSQL(RollbackException e) {
	PersistenceException persistenceException = (PersistenceException) e
			.getCause();
	/*
	 * Desde aquí ya no es estándar JEE6, estas son clases específicas de
	 * Hibernate y PostgreSQL dependiendo del proveedor JPA y del motor que
	 * se utilice esto habrá que adaptar
	 */
	ConstraintViolationException constraintViolationException = (ConstraintViolationException) persistenceException
			.getCause();
	BatchUpdateException batchUpdateException = (BatchUpdateException) constraintViolationException
			.getCause();
	Exception psqlException = batchUpdateException.getNextException();
	String msg = psqlException.getLocalizedMessage();
	logger.error("Error al realizar el update: " + msg);
	FacesContext.getCurrentInstance().addMessage(null,
			new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));
}
 
开发者ID:alefq,项目名称:tekoporu-postgresql,代码行数:20,代码来源:UsuarioEditMB.java

示例2: insert

import java.sql.BatchUpdateException; //导入方法依赖的package包/类
public void insert() throws SQLException {
	try {
		statement.executeBatch();
	}
	catch (BatchUpdateException e) {
		throw e.getNextException();
	}
	finally {
		statement.close();
	}
}
 
开发者ID:quantumdb,项目名称:quantumdb,代码行数:12,代码来源:BatchInserter.java

示例3: getUnderlyingSQLException

import java.sql.BatchUpdateException; //导入方法依赖的package包/类
/**
 * This method will take care of finding the real underlying exception. When a jdbc or hibernate
 * exception occurs then the whole stack trace is not available in the log because the exception
 * does not return the underlying exception using the {@link Throwable#getCause()} but using the
 * {@link SQLException#getNextException()}.
 * 
 * @param throwable
 *          the throwable to analyze
 * @return the underlying sql exception or the original throwable if none found
 */
public static Throwable getUnderlyingSQLException(Throwable throwable) {

  if (throwable instanceof BatchUpdateException
      && ((BatchUpdateException) throwable).getNextException() != null) {
    return ((BatchUpdateException) throwable).getNextException();
  }
  if (throwable.getCause() instanceof BatchUpdateException
      && ((BatchUpdateException) throwable.getCause()).getNextException() != null) {
    final BatchUpdateException bue = (BatchUpdateException) throwable.getCause();
    return bue.getNextException();
  }
  if (throwable.getCause() instanceof org.hibernate.exception.GenericJDBCException
      && ((org.hibernate.exception.GenericJDBCException) throwable.getCause()).getSQLException()
          .getNextException() != null) {
    final org.hibernate.exception.GenericJDBCException gjdbce = (org.hibernate.exception.GenericJDBCException) throwable
        .getCause();
    return gjdbce.getSQLException().getNextException();
  }
  if (throwable.getCause() instanceof org.hibernate.exception.ConstraintViolationException
      && ((org.hibernate.exception.ConstraintViolationException) throwable.getCause())
          .getSQLException().getNextException() != null) {
    final org.hibernate.exception.ConstraintViolationException cve = (org.hibernate.exception.ConstraintViolationException) throwable
        .getCause();
    return cve.getSQLException().getNextException();
  }
  return throwable;
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:38,代码来源:DbUtility.java

示例4: hibernateData

import java.sql.BatchUpdateException; //导入方法依赖的package包/类
/**
 * Hibernate data.
 *
 * @param article
 *            the article
 * @param session
 *            the session
 * @return true, if successful
 */
public synchronized boolean hibernateData(final NewsArticle article, final Session session) {
	Transaction tx = null;

	HibernateHelper.logger.debug("hibernateData: " + article.getArticleId());

	final Location location = null;
	final String gender = null;
	try {
		tx = session.beginTransaction();
		tx.begin();

		final UsenetUser poster = this.createUsenetUser(article, session, location, gender);

		final Message message = this.createMessage(article, null, poster);

		this.storeNewsgroups(article.getNewsgroupsList(), message, session);

		tx.commit();

	}
	catch (Exception e) {
		if (e instanceof GenericJDBCException) {
			e = (Exception) e.getCause();
		}
		if (e instanceof BatchUpdateException) {
			final BatchUpdateException buex = (BatchUpdateException) e;
			System.err.println("Contents of BatchUpdateException:");
			System.err.println(" Update counts: ");
			final int[] updateCounts = buex.getUpdateCounts();
			for (int i = 0; i < updateCounts.length; i++) {
				System.err.println("  Statement " + i + ":" + updateCounts[i]);
			}
			System.err.println(" Message: " + buex.getMessage());
			System.err.println(" SQLSTATE: " + buex.getSQLState());
			System.err.println(" Error code: " + buex.getErrorCode());
			System.err.println(" Article: " + article);

			SQLException ex = buex.getNextException();
			while (ex != null) {
				System.err.println("SQL exception:");
				System.err.println(" Message: " + ex.getMessage());
				System.err.println(" SQLSTATE: " + ex.getSQLState());
				System.err.println(" Error code: " + ex.getErrorCode());
				System.err.println(" Error code: " + ex.getErrorCode());

				ex = ex.getNextException();
			}

		}
		HibernateHelper.logger.error("Failed to store message", e);
		e.printStackTrace();
		if (tx != null) {
			try {
				tx.rollback();
			}
			catch (final HibernateException e1) {
				e1.printStackTrace();
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:leonarduk,项目名称:unison,代码行数:73,代码来源:HibernateHelper.java


注:本文中的java.sql.BatchUpdateException.getNextException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。