Best code examples for Java 8 SQLException class (java.sql.SQLException)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SQLException class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 SQLException examples from Open Source projects
This code example shows how to use the following methods: getMessage, getErrorCode, getSQLState
	 * @param sql the offending SQL statement 
	 * @param ex the root cause 
	 */ 
	public UncategorizedSQLException(String task, String sql, SQLException ex) {
		super(task + "; uncategorized SQLException for SQL [" + sql + "]; SQL state [" +
				ex.getSQLState() + "]; error code [" + ex.getErrorCode() + "]; " + ex.getMessage(), ex);
		this.sql = sql;
	} 
 
 
	/** 
	 * Return the underlying SQLException. 
	 */ 
	public SQLException getSQLException() {
		return (SQLException) getCause();
	} 
 
	/** 
	 * Return the SQL that led to the problem. 
	 */ 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getClass, getNextException, getSQLState
 * @author Thomas Risberg 
 * @see java.sql.SQLException#getSQLState() 
 * @see SQLErrorCodeSQLExceptionTranslator 
 */ 
public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLExceptionTranslator { 
 
	private static final Set<String> BAD_SQL_GRAMMAR_CODES = new HashSet<String>(8); 
 
	private static final Set<String> DATA_INTEGRITY_VIOLATION_CODES = new HashSet<String>(8); 
 
	private static final Set<String> DATA_ACCESS_RESOURCE_FAILURE_CODES = new HashSet<String>(8); 
 
	private static final Set<String> TRANSIENT_DATA_ACCESS_RESOURCE_CODES = new HashSet<String>(8); 
 
	private static final Set<String> CONCURRENCY_FAILURE_CODES = new HashSet<String>(4); 
 
 
	static { 
		BAD_SQL_GRAMMAR_CODES.add("07");	// Dynamic SQL error 
		BAD_SQL_GRAMMAR_CODES.add("21");	// Cardinality violation 

8
CodeRank
This code example shows how to use the following methods:
 
public class SybaseExceptionSorterTest extends TestCase {
 
    public void test_false() throws Exception { 
        SybaseExceptionSorter sorter = new SybaseExceptionSorter();
        Assert.assertFalse(sorter.isExceptionFatal(new SQLException()));
    } 
     
    public void test_false_2() throws Exception { 
        SybaseExceptionSorter sorter = new SybaseExceptionSorter();
        Assert.assertFalse(sorter.isExceptionFatal(new SQLException("xxx")));
    } 
     
    public void test_true() throws Exception { 
        SybaseExceptionSorter sorter = new SybaseExceptionSorter();
        Assert.assertTrue(sorter.isExceptionFatal(new SQLException("JZ0C0")));
    } 
     
    public void test_true_1() throws Exception { 
        SybaseExceptionSorter sorter = new SybaseExceptionSorter();
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: printStackTrace
            throw new RuntimeException("naming error creating initial context", e);
        } 
        try { 
            dataSource.getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new RuntimeException("datasource error getting connection", e);
        } 
 
        return null; 
    } 
 
    public static boolean getClosedByReaperThread() { 
        return closedByReaperThread.get();
    } 
 
    private Object close() {
        String currentThreadName = Thread.currentThread().getName();
        boolean isBackgroundReaperThread =
            TxUtils.isTransactionManagerTimeoutThread(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getMessage
      } catch (SQLException e) {
        try { 
          connection.rollback();
        } 
        catch (SQLException ex) {
          LOG.warn(StringUtils.stringifyException(ex));
        } 
        throw new IOException(e.getMessage());
      } finally { 
        try { 
          statement.close();
          connection.close();
        } 
        catch (SQLException ex) {
          throw new IOException(ex.getMessage());
        } 
      } 
    } 
 
    /** {@inheritDoc} */ 
Full Snippet Info
8
CodeRank
Related Java 8 SQLException Questions & Answers:
See Code Examples for Java 8 SQLException Methods: