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


Java Statement.getWarnings方法代码示例

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


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

示例1: testBug10630

import java.sql.Statement; //导入方法依赖的package包/类
/**
 * Tests fix for BUG#10630, Statement.getWarnings() fails with NPE if
 * statement has been closed.
 */
public void testBug10630() throws Exception {
    Connection conn2 = null;
    Statement stmt2 = null;

    try {
        conn2 = getConnectionWithProps((Properties) null);
        stmt2 = conn2.createStatement();

        conn2.close();
        stmt2.getWarnings();
        fail("Should've caught an exception here");
    } catch (SQLException sqlEx) {
        assertEquals(SQLError.SQL_STATE_ILLEGAL_ARGUMENT, sqlEx.getSQLState());
    } finally {
        if (stmt2 != null) {
            stmt2.close();
        }

        if (conn2 != null) {
            conn2.close();
        }
    }
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:28,代码来源:StatementRegressionTest.java

示例2: handleWarnings

import java.sql.Statement; //导入方法依赖的package包/类
/**
 * Throw an SQLWarningException if we're not ignoring warnings,
 * else log the warnings (at debug level).
 * @param stmt the current JDBC statement
 * @throws SQLWarningException if not ignoring warnings
 * @see org.springframework.jdbc.SQLWarningException
 */
protected void handleWarnings(Statement stmt) throws SQLException {
	if (isIgnoreWarnings()) {
		if (logger.isDebugEnabled()) {
			SQLWarning warningToLog = stmt.getWarnings();
			while (warningToLog != null) {
				logger.debug("SQLWarning ignored: SQL state '" + warningToLog.getSQLState() + "', error code '" +
						warningToLog.getErrorCode() + "', message [" + warningToLog.getMessage() + "]");
				warningToLog = warningToLog.getNextWarning();
			}
		}
	}
	else {
		handleWarnings(stmt.getWarnings());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:JdbcTemplate.java

示例3: execute

import java.sql.Statement; //导入方法依赖的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: runDDL

import java.sql.Statement; //导入方法依赖的package包/类
public void runDDL(String ddl) {
        try {
//            System.err.println("Executing " + ddl);
            Statement stmt = dbconn.createStatement();
            /*boolean success =*/ stmt.execute(ddl);
            SQLWarning warn = stmt.getWarnings();
            if (warn != null)
                sqlLog.warn(warn.getMessage());
            //LOG.info("SQL DDL execute result: " + (success ? "true" : "false"));
        } catch (SQLException e) {
            // IGNORE??? hostLog.l7dlog( Level.ERROR, LogKeys.host_Backend_RunDDLFailed.name(), new Object[] { ddl }, e);
        }

    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:15,代码来源:HsqlBackend.java


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