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


Java SQLWarning类代码示例

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


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

示例1: getWarnings

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * The first warning reported by calls on this Statement is returned. A
 * Statement's execute methods clear its java.sql.SQLWarning chain.
 * Subsequent Statement warnings will be chained to this
 * java.sql.SQLWarning.
 * 
 * <p>
 * The Warning chain is automatically cleared each time a statement is (re)executed.
 * </p>
 * 
 * <p>
 * <B>Note:</B> If you are processing a ResultSet then any warnings associated with ResultSet reads will be chained on the ResultSet object.
 * </p>
 * 
 * @return the first java.sql.SQLWarning or null
 * 
 * @exception SQLException
 *                if a database access error occurs
 */
public java.sql.SQLWarning getWarnings() throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {

        if (this.clearWarningsCalled) {
            return null;
        }

        if (this.connection.versionMeetsMinimum(4, 1, 0)) {
            SQLWarning pendingWarningsFromServer = SQLError.convertShowWarningsToSQLWarnings(this.connection);

            if (this.warningChain != null) {
                this.warningChain.setNextWarning(pendingWarningsFromServer);
            } else {
                this.warningChain = pendingWarningsFromServer;
            }

            return this.warningChain;
        }

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

示例2: testBug18740

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Tests fix for BUG#18740 - Data truncation and getWarnings() only returns
 * last warning in set.
 * 
 * @throws Exception
 *             if the test fails.
 */
public void testBug18740() throws Exception {
    if (!versionMeetsMinimum(5, 0, 2)) {
        createTable("testWarnings", "(field1 smallint(6), field2 varchar(6), UNIQUE KEY field1(field1))");

        try {
            this.stmt.executeUpdate(
                    "INSERT INTO testWarnings VALUES (10001, 'data1'), (10002, 'data2 foo'), (10003, 'data3'), (10004999, 'data4'), (10005, 'data5')");
        } catch (SQLException sqlEx) {
            String sqlStateToCompare = "01004";

            if (isJdbc4()) {
                sqlStateToCompare = "22001";
            }

            assertEquals(sqlStateToCompare, sqlEx.getSQLState());
            assertEquals(sqlStateToCompare, sqlEx.getNextException().getSQLState());

            SQLWarning sqlWarn = this.stmt.getWarnings();
            assertEquals("01000", sqlWarn.getSQLState());
            assertEquals("01000", sqlWarn.getNextWarning().getSQLState());
        }
    }
}
 
开发者ID:JuanJoseFJ,项目名称:ProyectoPacientes,代码行数:31,代码来源:StatementRegressionTest.java

示例3: execute

import java.sql.SQLWarning; //导入依赖的package包/类
private void execute(boolean script, boolean export, Writer fileOutput, Statement statement, final String sql)
		throws IOException, SQLException {
	final SqlExceptionHelper sqlExceptionHelper = new SqlExceptionHelper();

	String formatted = formatter.format( sql );
       if (delimiter != null) formatted += delimiter;
       if (script) System.out.println(formatted);
       LOG.debug(formatted);
	if ( outputFile != null ) {
		fileOutput.write( formatted + "\n" );
	}
	if ( export ) {

		statement.executeUpdate( sql );
		try {
			SQLWarning warnings = statement.getWarnings();
			if ( warnings != null) {
				sqlExceptionHelper.logAndClearWarnings( connectionHelper.getConnection() );
			}
		}
		catch( SQLException sqle ) {
               LOG.unableToLogSqlWarnings(sqle);
		}
	}

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:SchemaExport.java

示例4: test14

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

示例5: test10

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Serialize a SQLWarning and make sure you can read it back properly
 */
@Test
public void test10() throws Exception {
    SQLWarning e = new SQLWarning(reason, state, errorCode, t);
    SQLWarning ex1 = createSerializedException(e);
    assertTrue(reason.equals(ex1.getMessage())
            && ex1.getSQLState().equals(state)
            && cause.equals(ex1.getCause().toString())
            && ex1.getErrorCode() == errorCode);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:SQLWarningTests.java

示例6: test6

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Create SQLWarning with message, SQLState, and Throwable
 */
@Test
public void test6() {
    SQLWarning ex = new SQLWarning(reason, state, t);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && cause.equals(ex.getCause().toString())
            && ex.getErrorCode() == 0);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:SQLWarningTests.java

示例7: setWarnings

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Sets the warning chain
 */
void setWarnings(SQLWarning w) {

    synchronized (rootWarning_mutex) {
        rootWarning = w;
    }
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:10,代码来源:JDBCConnection.java

示例8: addWarning

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Adds another SQLWarning to this Connection object's warning chain.
 *
 * @param w the SQLWarning to add to the chain
 */
void addWarning(SQLWarning w) {

    // PRE:  w is never null
    synchronized (rootWarning_mutex) {
        if (rootWarning == null) {
            rootWarning = w;
        } else {
            rootWarning.setNextWarning(w);
        }
    }
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:17,代码来源:JDBCConnection.java

示例9: walkWarnings

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Generic algorithm to walk the hierarchy of SQLWarnings
 *
 * @param warning The warning to walk
 * @param handler The handler
 */
public void walkWarnings(
		SQLWarning warning,
		WarningHandler handler) {
	if ( warning == null || handler.doProcess() ) {
		return;
	}
	handler.prepare( warning );
	while ( warning != null ) {
		handler.handleWarning( warning );
		warning = warning.getNextWarning();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:SqlExceptionHelper.java

示例10: test5

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Create SQLWarning with message, SQLState, errorCode, and Throwable
 */
@Test
public void test5() {
    SQLWarning ex = new SQLWarning(reason, state, errorCode, t);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && cause.equals(ex.getCause().toString())
            && ex.getErrorCode() == errorCode);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:SQLWarningTests.java

示例11: test8

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Create SQLWarning with null Throwable
 */
@Test
public void test8() {
    SQLWarning ex = new SQLWarning((Throwable) null);
    assertTrue(ex.getMessage() == null
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:SQLWarningTests.java

示例12: test1

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Create SQLWarning with no-arg constructor
 */
@Test
public void test1() {
    SQLWarning ex = new SQLWarning();
    assertTrue(ex.getMessage() == null
            && ex.getSQLState() == null
            && ex.getCause() == null
            && ex.getErrorCode() == 0);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:SQLWarningTests.java

示例13: test4

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Create SQLWarning with message, SQLState, and error code
 */
@Test
public void test4() {
    SQLWarning ex = new SQLWarning(reason, state, errorCode);
    assertTrue(ex.getMessage().equals(reason)
            && ex.getSQLState().equals(state)
            && ex.getCause() == null
            && ex.getErrorCode() == errorCode);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:SQLWarningTests.java

示例14: performPostExecute

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * processes chained warnings and any generated columns result set
 */
void performPostExecute() throws SQLException {

    resultOut.clearLobResults();

    generatedResult = null;

    if (resultIn == null) {
        return;
    }

    rootWarning = null;

    Result current = resultIn;

    while (current.getChainedResult() != null) {
        current = current.getUnlinkChainedResult();

        if (current.getType() == ResultConstants.WARNING) {
            SQLWarning w = JDBCUtil.sqlWarning(current);

            if (rootWarning == null) {
                rootWarning = w;
            } else {
                rootWarning.setNextWarning(w);
            }
        } else if (current.getType() == ResultConstants.ERROR) {
            errorResult = current;
        } else if (current.getType() == ResultConstants.GENERATED) {
            generatedResult = current;
        } else if (current.getType() == ResultConstants.DATA) {
            resultIn.addChainedResult(current);
        }
    }

    if (rootWarning != null) {
        connection.setWarnings(rootWarning);
    }
}
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:42,代码来源:JDBCStatementBase.java

示例15: test

import java.sql.SQLWarning; //导入依赖的package包/类
/**
 * Create SQLWarning and setting all objects to null
 */
@Test
public void test() {
    SQLWarning e = new SQLWarning(null, null, errorCode, null);
    assertTrue(e.getMessage() == null && e.getSQLState() == null
            && e.getCause() == null && e.getErrorCode() == errorCode);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:SQLWarningTests.java


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