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


Java SQLException.getCause方法代码示例

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


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

示例1: test12

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLSyntaxErrorException ex = new SQLSyntaxErrorException("Exception 1", t1);
    SQLSyntaxErrorException ex1 = new SQLSyntaxErrorException("Exception 2");
    SQLSyntaxErrorException ex2 = new SQLSyntaxErrorException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:SQLSyntaxErrorExceptionTests.java

示例2: test12

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLNonTransientException ex = new SQLNonTransientException("Exception 1", t1);
    SQLNonTransientException ex1 = new SQLNonTransientException("Exception 2");
    SQLNonTransientException ex2 = new SQLNonTransientException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:SQLNonTransientExceptionTests.java

示例3: validateAsync

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Asynchronously performs validation that the local representation is as up-to-date as the representation on the backing data store.
 *
 * @param shardMap
 *            Shard map to which the shard provider belongs.
 * @param conn
 *            Connection used for validation.
 * @return A task to await validation completion
 */
@Override
public Callable validateAsync(StoreShardMap shardMap,
        Connection conn) {
    Callable returnVal;
    try {
        log.info("PointMapping ValidateAsync Start; Connection: {}", conn.getMetaData().getURL());

        Stopwatch stopwatch = Stopwatch.createStarted();

        returnVal = ValidationUtils.validateMappingAsync(conn, this.getShardMapManager(), shardMap, this.getStoreMapping());

        stopwatch.stop();

        log.info("PointMapping ValidateAsync Complete; Connection: {} Duration:{}", conn.getMetaData().getURL(),
                stopwatch.elapsed(TimeUnit.MILLISECONDS));
    }
    catch (SQLException e) {
        e.printStackTrace();
        throw (ShardManagementException) e.getCause();
    }
    return returnVal;
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:32,代码来源:PointMapping.java

示例4: test12

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLTransientException ex = new SQLTransientException("Exception 1", t1);
    SQLTransientException ex1 = new SQLTransientException("Exception 2");
    SQLTransientException ex2 = new SQLTransientException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:SQLTransientExceptionTests.java

示例5: validate

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Performs validation that the local representation is as up-to-date as the representation on the backing data store.
 *
 * @param shardMap
 *            Shard map to which the shard provider belongs.
 * @param conn
 *            Connection used for validation.
 */
@Override
public void validate(StoreShardMap shardMap,
        Connection conn) {
    try {
        log.info("PointMapping Validate Start; Connection: {}", conn.getMetaData().getURL());
        Stopwatch stopwatch = Stopwatch.createStarted();

        ValidationUtils.validateMapping(conn, this.getShardMapManager(), shardMap, this.getStoreMapping());

        stopwatch.stop();

        log.info("PointMapping Validate Complete; Connection: {}; Duration:{}", conn.getMetaData().getURL(),
                stopwatch.elapsed(TimeUnit.MILLISECONDS));
    }
    catch (SQLException e) {
        e.printStackTrace();
        throw (ShardManagementException) e.getCause();
    }
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:28,代码来源:PointMapping.java

示例6: test12

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLTransientConnectionException ex =
            new SQLTransientConnectionException("Exception 1", t1);
    SQLTransientConnectionException ex1 =
            new SQLTransientConnectionException("Exception 2");
    SQLTransientConnectionException ex2 =
            new SQLTransientConnectionException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:SQLTransientConnectionExceptionTests.java

示例7: test06

import java.sql.SQLException; //导入方法依赖的package包/类
@Test
public void test06() {
    SQLException ex = new SyncProviderException("Exception 1");
    ex.initCause(t1);
    SyncProviderException ex1 = new SyncProviderException("Exception 2");
    SyncProviderException ex2 = new SyncProviderException("Exception 3");
    ex2.initCause(t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    while (ex != null) {
        assertTrue(msgs[num++].equals(ex.getMessage()));
        Throwable c = ex.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        ex = ex.getNextException();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:SyncProviderExceptionTests.java

示例8: test12

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    SQLInvalidAuthorizationSpecException ex
            = new SQLInvalidAuthorizationSpecException("Exception 1", t1);
    SQLInvalidAuthorizationSpecException ex1
            = new SQLInvalidAuthorizationSpecException("Exception 2");
    SQLInvalidAuthorizationSpecException ex2
            = new SQLInvalidAuthorizationSpecException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:SQLInvalidAuthorizationSpecExceptionTests.java

示例9: test16

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test16() {
    BatchUpdateException ex = new BatchUpdateException("Exception 1", uc,  t1);
    BatchUpdateException ex1 = new BatchUpdateException("Exception 2", uc);
    BatchUpdateException ex2 = new BatchUpdateException("Exception 3", uc, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    SQLException sqe = ex;
    int num = 0;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:BatchUpdateExceptionTests.java

示例10: test07

import java.sql.SQLException; //导入方法依赖的package包/类
@Test
public void test07() {
    RowSetWarning ex = new RowSetWarning("Exception 1");
    ex.initCause(t1);
    RowSetWarning ex1 = new RowSetWarning("Exception 2");
    RowSetWarning ex2 = new RowSetWarning("Exception 3");
    ex2.initCause(t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:RowSetWarningTests.java

示例11: getClientInfoProviderImpl

import java.sql.SQLException; //导入方法依赖的package包/类
public JDBC4ClientInfoProvider getClientInfoProviderImpl() throws SQLException {
    synchronized (getConnectionMutex()) {
        if (this.infoProvider == null) {
            try {
                try {
                    this.infoProvider = (JDBC4ClientInfoProvider) Util.getInstance(getClientInfoProvider(), new Class<?>[0], new Object[0],
                            getExceptionInterceptor());
                } catch (SQLException sqlEx) {
                    if (sqlEx.getCause() instanceof ClassCastException) {
                        // try with package name prepended
                        this.infoProvider = (JDBC4ClientInfoProvider) Util.getInstance("com.mysql.jdbc." + getClientInfoProvider(), new Class<?>[0],
                                new Object[0], getExceptionInterceptor());
                    }
                }
            } catch (ClassCastException cce) {
                throw SQLError.createSQLException(Messages.getString("JDBC4Connection.ClientInfoNotImplemented", new Object[] { getClientInfoProvider() }),
                        SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor());
            }

            this.infoProvider.initialize(this, this.props);
        }

        return this.infoProvider;
    }
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:26,代码来源:JDBC4Connection.java

示例12: test12

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLException ex = new SQLException("Exception 1", t1);
    SQLException ex1 = new SQLException("Exception 2");
    SQLException ex2 = new SQLException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    while (ex != null) {
        assertTrue(msgs[num++].equals(ex.getMessage()));
        Throwable c = ex.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        ex = ex.getNextException();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:SQLExceptionTests.java

示例13: test12

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * traditional while loop
 */
@Test
public void test12() {
    DataTruncation ex = new DataTruncation(index, parameter, onRead,
            dataSize, transferSize, t1);
    DataTruncation ex1 = new DataTruncation(index, parameter, onRead,
            dataSize, transferSize);
    DataTruncation ex2 = new DataTruncation(index, parameter, onRead,
            dataSize, transferSize, t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(dtmsgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(dtmsgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:DataTruncationTests.java

示例14: test04

import java.sql.SQLException; //导入方法依赖的package包/类
@Test
public void test04() {
    SQLException ex = new SyncFactoryException("Exception 1");
    ex.initCause(t1);
    SyncFactoryException ex1 = new SyncFactoryException("Exception 2");
    SyncFactoryException ex2 = new SyncFactoryException("Exception 3");
    ex2.initCause(t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    while (ex != null) {
        assertTrue(msgs[num++].equals(ex.getMessage()));
        Throwable c = ex.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        ex = ex.getNextException();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:SyncFactoryExceptionTests.java

示例15: test12

import java.sql.SQLException; //导入方法依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct
 * using traditional while loop
 */
@Test
public void test12() {
    SQLTransactionRollbackException ex =
            new SQLTransactionRollbackException("Exception 1", t1);
    SQLTransactionRollbackException ex1 =
            new SQLTransactionRollbackException("Exception 2");
    SQLTransactionRollbackException ex2 =
            new SQLTransactionRollbackException("Exception 3", t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    SQLException sqe = ex;
    while (sqe != null) {
        assertTrue(msgs[num++].equals(sqe.getMessage()));
        Throwable c = sqe.getCause();
        while (c != null) {
            assertTrue(msgs[num++].equals(c.getMessage()));
            c = c.getCause();
        }
        sqe = sqe.getNextException();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:SQLTransactionRollbackExceptionTests.java


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