java.sql

Class SQLWarning

Implemented Interfaces:
Serializable
Known Direct Subclasses:
DataTruncation

public class SQLWarning
extends SQLException

An exception that provides information on database access warnings. Warnings are silently chained to the object whose method caused it to be reported.

Warnings may be retrieved from Connection, Statement, and ResultSet objects. Trying to retrieve a warning on a connection after it has been closed will cause an exception to be thrown. Similarly, trying to retrieve a warning on a statement after it has been closed or on a result set after it has been closed will cause an exception to be thrown. Note that closing a statement also closes a result set that it might have produced.

See Also:
Connection.getWarnings(), Statement.getWarnings(), ResultSet.getWarnings(), Serialized Form

Constructor Summary

SQLWarning()
Constructs a default SQLWarning object.
SQLWarning(String reason)
Constructs an SQLWarning object with the given value for a reason; SQLstate defaults to null, and vendorCode defaults to 0.
SQLWarning(String reason, String SQLstate)
Constructs an SQLWarning object with the given reason and SQLState; the vendorCode defaults to 0.
SQLWarning(String reason, String SQLstate, int vendorCode)
Constructs a fully-specified SQLWarning object initialized with the given values.

Method Summary

SQLWarning
getNextWarning()
Retrieves the warning chained to this SQLWarning object.
void
setNextWarning(SQLWarning w)
Adds an SQLWarning object to the end of the chain.

Methods inherited from class java.sql.SQLException

getErrorCode, getNextException, getSQLState, setNextException

Methods inherited from class java.lang.Throwable

fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

SQLWarning

public SQLWarning()
Constructs a default SQLWarning object. The reason defaults to null, SQLState defaults to null, and vendorCode defaults to 0.
Usages and Demos :

View More Examples of SQLWarning()
   1:         ThrowableHandler.addError(new NullPointerException());
   2:         ThrowableHandler.addWarning(new SQLWarning());
   3:         ThrowableHandler.add(new Exception());
   4: 
   5:         ArrayList errorListOne = listenerOne.getErrorList();

View Full Code Here

SQLWarning

public SQLWarning(String reason)
Constructs an SQLWarning object with the given value for a reason; SQLstate defaults to null, and vendorCode defaults to 0.
Parameters:
reason - a description of the warning
Usages and Demos :

View More Examples of SQLWarning(String reason)
   1:     {
   2:     new SQLWarning("Connection.close() called!").printStackTrace();
   3:     super.close();
   4:     }
   5: }

View Full Code Here
   1:     {
   2:         SQLWarning sqlw = new SQLWarning(getMessage(), getSQLState(), 
   3:             getErrorCode());
   4: 
   5:         sqlw.initCause(this);

View Full Code Here
   1:                             }
   2:                             setWarning(new SQLWarning(warn));
   3:                             m_log.warning(warn);
   4:         ...
   5:                     String warn = "Problem creating sql.  Check the query clauses for completeness";
   6:                     setWarning(new SQLWarning(warn));
   7:                     m_log.log(Level.WARNING, warn, e);
   8:                 }
   9:             }

View Full Code Here
   1:         
   2:         addWarning(new SQLWarning(warningMsgBuf.toString(), "01004"));
   3:     }
   4: 
   5:     private final String fixDecimalExponent(int parameterIndex, float f) {

View Full Code Here
   1:                     {
   2:                         se = new SQLWarning(strbuf.toString(), sqlstate);
   3:                         ce = se;
   4:         ...
   5:                     {
   6:                         ne = new SQLWarning(strbuf.toString(), sqlstate);
   7:                         ce.setNextException(ne);
   8:         ...
   9:             {
  10:                 se = new SQLWarning(strbuf.toString(), sqlstate);
  11:                 ce = se;

View Full Code Here

SQLWarning

public SQLWarning(String reason,
                  String SQLstate)
Constructs an SQLWarning object with the given reason and SQLState; the vendorCode defaults to 0.
Parameters:
reason - a description of the warning
SQLstate - an XOPEN code identifying the warning

SQLWarning

public SQLWarning(String reason,
                  String SQLstate,
                  int vendorCode)
Constructs a fully-specified SQLWarning object initialized with the given values.
Parameters:
reason - a description of the warning
SQLstate - an XOPEN code identifying the warning
vendorCode - a database vendor-specific warning code
Usages and Demos :

View More Examples of SQLWarning(String reason,String SQLstate,int vendorCode)
   1:         String        state = StandardException.getSQLStateFromIdentifier(messageId);
   2:         SQLWarning    sqlw = new SQLWarning(message, state, ExceptionSeverity.WARNING_SEVERITY);
   3: 
   4:         return sqlw;
   5:     }

View Full Code Here

Method Details

getNextWarning

public SQLWarning getNextWarning()
Retrieves the warning chained to this SQLWarning object.
Returns:
the next SQLException in the chain; null if none

setNextWarning

public void setNextWarning(SQLWarning w)
Adds an SQLWarning object to the end of the chain.
Parameters:
w - the new end of the SQLException chain
Usages and Demos :

View More Examples of setNextWarning(SQLWarning w)
   1:        if(somethingWrongHappened) {
   2:            SQLWarning rootWarning =
   3:         ...
   4:              new SQLWarning("Employee Salary Business rules not properly regarded");
   5:         ...
   6:            SQLWarning containedWarning =
   7:              new SQLWarning("Salary over $200,000.");
   8:         ...
   9: 
  10:            rootWarning.setNextWarning(containedWarning);

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.SQLWarning;
   3: import java.util.ArrayList;
   4:         ...
   5:     private java.sql.ResultSet targetVTI;
   6:     private SQLWarning warnings;
   7: 
   8:         ...
   9: 
  10:     public void addWarning(SQLWarning w)
  11:     {
  12:         ...
  13:         else
  14:             warnings.setNextWarning(w);

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.SQLWarning;
   3: import java.sql.Statement;
   4:         ...
   5:     final EmbedConnection rootConnection;
   6:     private SQLWarning         topWarning;
   7:     private InternalDriver factory;
   8:         ...
   9: 
  10:     public final synchronized SQLWarning getWarnings() throws SQLException {
  11:         checkIfClosed();
  12:         ...
  13: 
  14:         topWarning.setNextWarning(newWarning);

View Full Code Here
   1: import java.sql.SQLException;
   2: import java.sql.SQLWarning;
   3: import java.sql.ResultSetMetaData;
   4:         ...
   5:     private boolean forMetaData;
   6:     private SQLWarning topWarning;
   7: 
   8:         ...
   9:                 concurrencyOfThisResultSet = JDBC20Translation.CONCUR_READ_ONLY;
  10:                 SQLWarning w = StandardException.newWarning(SQLState.QUERY_NOT_QUALIFIED_FOR_UPDATABLE_RESULTSET);
  11:                 addWarning(w);
  12:         ...
  13:                 else
  14:                     topWarning.setNextWarning(w);

View Full Code Here