Java SQL ResultSet Print printWarnings(ResultSet resultSet)

Here you can find the source of printWarnings(ResultSet resultSet)

Description

print Warnings

License

Open Source License

Declaration

public static void printWarnings(ResultSet resultSet) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.ResultSet;
import java.sql.Statement;

import java.sql.SQLException;
import java.sql.SQLWarning;

public class Main {
    public static void printWarnings(ResultSet resultSet) throws SQLException {
        System.out.println("Resultset warnings begin:");
        if (resultSet != null) {
            SQLWarning warning = resultSet.getWarnings();
            if (warning != null)
                warning = warning.getNextWarning();
            if (warning != null)
                System.out.println("Message: " + warning.getMessage());
        }/*from ww  w  .  j ava  2 s.  c o  m*/
        System.out.println("Resultset warnings end");
    }

    public static void printWarnings(Statement stmt) throws SQLException {
        System.out.println("Resultset warnings begin:");
        if (stmt != null) {
            SQLWarning warning = stmt.getWarnings();
            if (warning != null)
                warning = warning.getNextWarning();
            if (warning != null)
                System.out.println("Message: " + warning.getMessage());
        }
        System.out.println("Resultset warnings end");
    }
}

Related

  1. printRow(ResultSet pk)
  2. printRsetTypeAndConcurrencyType(ResultSet rset)
  3. printSet(ResultSet set, int columns)
  4. printValues(final ResultSet resultSet)
  5. printView(ResultSet rs)