Spring Framework SQLErrorCodeSQLExceptionTranslator - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework SQLErrorCodeSQLExceptionTranslator class.

This code example shows how to use the following methods:
    } 
 
    private SQLExceptionTranslator translator() { 
        return ds == null 
            ? new SQLStateSQLExceptionTranslator() 
            : new SQLErrorCodeSQLExceptionTranslator(ds); 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
	 * @see org.springframework.jdbc.support.SQLStateSQLExceptionTranslator 
	 */ 
	static SQLExceptionTranslator newJdbcExceptionTranslator(Object connectionFactory) { 
		// Check for PersistenceManagerFactory's DataSource. 
		if (connectionFactory instanceof DataSource) { 
			return new SQLErrorCodeSQLExceptionTranslator((DataSource) connectionFactory); 
		} 
		else { 
			return new SQLStateSQLExceptionTranslator(); 
		} 
	} 
 
	/** 
	 * Obtain a JDO PersistenceManager via the given factory. Is aware of a 
	 * corresponding PersistenceManager bound to the current thread, 
	 * for example when using JdoTransactionManager. Will create a new 
	 * PersistenceManager else, if "allowCreate" is {@code true}. 
	 * @param pmf PersistenceManagerFactory to create the PersistenceManager with 
	 * @param allowCreate if a non-transactional PersistenceManager should be created 
	 * when no transactional PersistenceManager can be found for the current thread 
5
CodeRank
This code example shows how to use the following methods:
    private SQLExceptionTranslator exceptionTranslator; 
 
    public SQLExceptionTranslatingThrowsAdvice(DataSource dataSource) { 
        super(); 
        if (dataSource != null) { 
            this.exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(dataSource); 
        } 
        else { 
            this.exceptionTranslator = new SQLStateSQLExceptionTranslator(); 
        } 
    } 
 
    public void afterThrowing(Method method, Object[] args, Object target, DBIException ex) throws Throwable { 
        Throwable t = ex.getCause(); 
        String sql = ((Handle)target).toString(); // we really want the failing SQL statement here - is that possible?? 
        if (t instanceof SQLException) { 
            throw exceptionTranslator.translate("DBI", sql, (SQLException)t); 
        } 
        else 
            throw new DataRetrievalFailureException("DBI Exception:" + ex.getMessage(), t); 
5
CodeRank
This code example shows how to use the following methods:
package org.ovirt.engine.core.dal.dbbroker; 
 
import javax.sql.DataSource; 
 
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator; 
 
public class CustomSQLErrorCodeSQLExceptionTranslator extends SQLErrorCodeSQLExceptionTranslator { 
 
    CustomSQLErrorCodeSQLExceptionTranslator(DataSource datasource) { 
        super(datasource); 
    } 
} 

4
CodeRank
This code example shows how to use the following methods:
	 */ 
	public SQLExceptionTranslator getExceptionTranslator() { 
		if (this.exceptionTranslator == null) { 
			DataSource ds = getDataSource(); 
			if (ds != null) { 
				return new SQLErrorCodeSQLExceptionTranslator(ds); 
			} 
			return new SQLStateSQLExceptionTranslator(); 
		} 
		return this.exceptionTranslator; 
	} 
 
	/** 
	 * Set whether to lazily initialize the SQLExceptionTranslator for this accessor, 
	 * on first encounter of a SQLException. Default is "true"; can be switched to 
	 * "false" for initialization on startup. 
	 * <p>Early initialization only applies if <code>afterPropertiesSet</code> is called. 
	 * 
	 * @see #getExceptionTranslator 
	 * @see #afterPropertiesSet 
4
CodeRank
This code example shows how to use the following methods:
  /** 
   * Initializes the internal translator reference. 
   */ 
  private synchronized void initExceptionTranslator() { 
    if (this.exceptionTranslator == null) { 
      this.exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(this.dataSource); 
    } 
  } 
 
} 
4
CodeRank
This code example shows how to use the following methods:
package org.ovirt.engine.core.dal.dbbroker; 
 
import java.io.IOException;
import java.util.Properties;
 
import javax.sql.DataSource;
 
import org.ovirt.engine.core.utils.EngineLocalConfig; 
import org.ovirt.engine.core.utils.ResourceUtils; 
import org.ovirt.engine.core.utils.ejb.ContainerManagedResourceType; 
import org.ovirt.engine.core.utils.ejb.EjbUtils; 
import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
 
/** 
 * A locator singleton for looking up (and initializing) DbFacade instance 
 */ 
public class DbFacadeLocator { 

4
CodeRank