站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

SQLStateSQLExceptionTranslator (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.jdbc.support
Class SQLStateSQLExceptionTranslator

java.lang.Object
  extended by org.springframework.jdbc.support.SQLStateSQLExceptionTranslator
All Implemented Interfaces:
SQLExceptionTranslator

public class SQLStateSQLExceptionTranslator
extends Object
implements SQLExceptionTranslator

SQLExceptionTranslator implementation that analyzes the SQL state in the SQLException.

Not able to diagnose all problems, but is portable between databases and does not require special initialization (no database vendor detection, etc.). For more precise translation, consider SQLErrorCodeSQLExceptionTranslator.

Author:
Rod Johnson, Juergen Hoeller
See Also:
SQLException.getSQLState(), SQLErrorCodeSQLExceptionTranslator

Field Summary
protected  Log logger
          Logger available to subclasses
 
Constructor Summary
SQLStateSQLExceptionTranslator()
           
 
Method Summary
protected  String buildMessage(String task, String sql, SQLException ex)
          Build a message String for the given SQLException.
 DataAccessException translate(String task, String sql, SQLException ex)
          Translate the given SQLException into a generic DataAccessException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger available to subclasses

Constructor Detail

SQLStateSQLExceptionTranslator

public SQLStateSQLExceptionTranslator()
Method Detail

translate

public DataAccessException translate(String task,
                                     String sql,
                                     SQLException ex)
Description copied from interface: SQLExceptionTranslator
Translate the given SQLException into a generic DataAccessException.

Specified by:
translate in interface SQLExceptionTranslator
Parameters:
task - readable text describing the task being attempted
sql - SQL query or update that caused the problem. May be null.
ex - the offending SQLException
Returns:
the DataAccessException to throw

buildMessage

protected String buildMessage(String task,
                              String sql,
                              SQLException ex)
Build a message String for the given SQLException.

Called when creating an instance of a generic DataAccessException class.

Parameters:
task - readable text describing the task being attempted
sql - the SQL statement that caused the problem. May be null.
ex - the offending SQLException
Returns:
the message String to use

The Spring Framework

Copyright © 2002-2007 The Spring Framework.