List of usage examples for org.hibernate JDBCException getSQLState
public String getSQLState()
From source file:edu.psu.iam.cpr.core.service.helper.ServiceHelper.java
License:Apache License
/** * This routine is used to handle exceptions of the JDBC type. * @param log4jLogger contains a log4j Logger instance. * @param serviceCoreReturn contains the service core return instance. * @param db contains a database connection. * @param e contains the JDBCEXception exception information. * @return contains the formatted String. *//*from ww w . j a va 2 s . co m*/ public String handleJDBCException(Logger log4jLogger, ServiceCoreReturn serviceCoreReturn, Database db, JDBCException e) { String sqlState = e.getSQLState(); sqlState = (sqlState == null) ? "N/A" : sqlState; int errorCode = e.getErrorCode(); String exceptionMessage = e.getMessage(); exceptionMessage = (exceptionMessage == null) ? "EMPTY" : exceptionMessage; final StringBuilder sb = new StringBuilder(BUFFER_SIZE); sb.append("Database Exception: "); sb.append("Message = "); sb.append(exceptionMessage); sb.append(", Error Code = "); sb.append(errorCode); sb.append(", SQL State = "); sb.append(sqlState); String formattedException = sb.toString(); log4jLogger.info(formattedException); db.rollbackSession(); return formattedException; }
From source file:edu.psu.iam.cpr.service.helper.ServiceHelper.java
License:Apache License
/** * This routine is used to handle exceptions of the JDBC type. * @param log4jLogger contains a log4j Logger instance. * @param serviceCoreReturn contains the service core return instance. * @param db contains a database connection. * @param e contains the JDBCEXception exception information. * @return contains the formatted String. */// w w w . j a va 2 s . c o m public String handleJDBCException(Logger log4jLogger, ServiceCoreReturn serviceCoreReturn, Database db, JDBCException e) { String sqlState = e.getSQLState(); sqlState = (sqlState == null) ? "N/A" : sqlState; int errorCode = e.getErrorCode(); String exceptionMessage = e.getMessage(); exceptionMessage = (exceptionMessage == null) ? "EMPTY" : exceptionMessage; StringBuffer sb = new StringBuffer(BUFFER_SIZE); sb.append("Database Exception: "); sb.append("Message = "); sb.append(exceptionMessage); sb.append(", Error Code = "); sb.append(errorCode); sb.append(", SQL State = "); sb.append(sqlState); String formattedException = sb.toString(); try { serviceCoreReturn.getServiceLogTable().endLog(db, formattedException); } catch (Exception e1) { } log4jLogger.info(formattedException); db.rollbackSession(); return formattedException; }
From source file:org.springframework.orm.hibernate3.HibernateJdbcException.java
License:Apache License
public HibernateJdbcException(JDBCException ex) { super("JDBC exception on Hibernate data access: SQLException for SQL [" + ex.getSQL() + "]; SQL state [" + ex.getSQLState() + "]; error code [" + ex.getErrorCode() + "]; " + ex.getMessage(), ex); }