本文整理汇总了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();
}
}
}
示例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());
}
}
示例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);
}
}
}
示例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);
}
}