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


Java DataTruncation类代码示例

本文整理汇总了Java中java.sql.DataTruncation的典型用法代码示例。如果您正苦于以下问题:Java DataTruncation类的具体用法?Java DataTruncation怎么用?Java DataTruncation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testBug3804

import java.sql.DataTruncation; //导入依赖的package包/类
/**
 * Tests fix for BUG#3804, data truncation on server should throw
 * DataTruncation exception.
 * 
 * @throws Exception
 *             if the test fails
 */
public void testBug3804() throws Exception {
    if (versionMeetsMinimum(4, 1)) {
        try {
            this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug3804");
            this.stmt.executeUpdate("CREATE TABLE testBug3804 (field1 VARCHAR(5))");

            boolean caughtTruncation = false;

            try {
                this.stmt.executeUpdate("INSERT INTO testBug3804 VALUES ('1234567')");
            } catch (DataTruncation truncationEx) {
                caughtTruncation = true;
                System.out.println(truncationEx);
            }

            assertTrue("Data truncation exception should've been thrown", caughtTruncation);
        } finally {
            this.stmt.executeUpdate("DROP TABLE IF EXISTS testBug3804");
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:29,代码来源:StatementRegressionTest.java

示例2: test

import java.sql.DataTruncation; //导入依赖的package包/类
/**
 * Create DataTruncation object indicating a truncation on read
 */
@Test
public void test() {
    onRead = true;
    DataTruncation e = new DataTruncation(index, parameter, onRead,
            dataSize, transferSize);
    assertTrue(e.getMessage().equals(dtReason)
            && e.getSQLState().equals(READ_TRUNCATION)
            && e.getCause() == null
            && e.getErrorCode() == dterrorCode
            && e.getParameter() == parameter
            && e.getRead() == onRead
            && e.getDataSize() == dataSize
            && e.getTransferSize() == transferSize
            && e.getIndex() == index);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:DataTruncationTests.java

示例3: test1

import java.sql.DataTruncation; //导入依赖的package包/类
/**
 * Create DataTruncation object indicating a truncation on write
 */
@Test
public void test1() {
    onRead = false;
    DataTruncation e = new DataTruncation(index, parameter, onRead,
            dataSize, transferSize);
    assertTrue(e.getMessage().equals(dtReason)
            && e.getSQLState().equals(WRITE_TRUNCATION)
            && e.getCause() == null
            && e.getErrorCode() == dterrorCode
            && e.getParameter() == parameter
            && e.getRead() == onRead
            && e.getDataSize() == dataSize
            && e.getTransferSize() == transferSize
            && e.getIndex() == index);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:DataTruncationTests.java

示例4: test2

import java.sql.DataTruncation; //导入依赖的package包/类
/**
 * Create DataTruncation object indicating a truncation on read with a
 * Throwable
 */
@Test
public void test2() {
    onRead = true;
    DataTruncation e = new DataTruncation(index, parameter, onRead,
            dataSize, transferSize, t);
    assertTrue(e.getMessage().equals(dtReason)
            && e.getSQLState().equals(READ_TRUNCATION)
            && cause.equals(e.getCause().toString())
            && e.getErrorCode() == dterrorCode
            && e.getParameter() == parameter
            && e.getRead() == onRead
            && e.getDataSize() == dataSize
            && e.getTransferSize() == transferSize
            && e.getIndex() == index);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:DataTruncationTests.java

示例5: test3

import java.sql.DataTruncation; //导入依赖的package包/类
/**
 * Create DataTruncation object indicating a truncation on read with null
 * specified for the Throwable
 */
@Test
public void test3() {
    onRead = true;;
    DataTruncation e = new DataTruncation(index, parameter, onRead,
            dataSize, transferSize, null);
    assertTrue(e.getMessage().equals(dtReason)
            && e.getSQLState().equals(READ_TRUNCATION)
            && e.getCause() == null
            && e.getErrorCode() == dterrorCode
            && e.getParameter() == parameter
            && e.getRead() == onRead
            && e.getDataSize() == dataSize
            && e.getTransferSize() == transferSize
            && e.getIndex() == index);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:DataTruncationTests.java

示例6: test4

import java.sql.DataTruncation; //导入依赖的package包/类
/**
 * Create DataTruncation object indicating a truncation on read and you can
 * pass a -1 for the index
 */
@Test
public void test4() {
    onRead = true;
    int negIndex = -1;
    DataTruncation e = new DataTruncation(negIndex, parameter, onRead,
            dataSize, transferSize);
    assertTrue(e.getMessage().equals(dtReason)
            && e.getSQLState().equals(READ_TRUNCATION)
            && e.getCause() == null
            && e.getErrorCode() == dterrorCode
            && e.getParameter() == parameter
            && e.getRead() == onRead
            && e.getDataSize() == dataSize
            && e.getTransferSize() == transferSize
            && e.getIndex() == negIndex);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:DataTruncationTests.java

示例7: test5

import java.sql.DataTruncation; //导入依赖的package包/类
/**
 * Serialize a DataTruncation and make sure you can read it back properly
 */
@Test
public void test5() throws Exception {
    DataTruncation e = new DataTruncation(index, parameter, onRead,
            dataSize, transferSize);
    DataTruncation ex1 = createSerializedException(e);
    assertTrue(e.getMessage().equals(dtReason)
            && e.getSQLState().equals(READ_TRUNCATION)
            && e.getCause() == null
            && e.getErrorCode() == dterrorCode
            && e.getParameter() == parameter
            && e.getRead() == onRead
            && e.getDataSize() == dataSize
            && e.getTransferSize() == transferSize
            && e.getIndex() == index);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:DataTruncationTests.java

示例8: test11

import java.sql.DataTruncation; //导入依赖的package包/类
/**
 * Validate that the ordering of the returned Exceptions is correct using
 * for-each loop
 */
@Test
public void test11() {
    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;
    for (Throwable e : ex) {
        assertTrue(dtmsgs[num++].equals(e.getMessage()));
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:DataTruncationTests.java

示例9: test12

import java.sql.DataTruncation; //导入依赖的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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:DataTruncationTests.java


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