Java Utililty Methods SQL Warning

List of utility methods to do SQL Warning

  1. HOME
  2. Java
  3. S
  4. SQL Warning

Description

The list of methods to do SQL Warning are organized into topic(s).

Method

void clearWarnings(Connection rawConnection)
clear Warnings
rawConnection.clearWarnings();
Throwable getCause(Throwable throwable)

Introspects the Throwable to obtain the cause.

The method searches for methods with specific names that return a Throwable object.

return getCause(throwable, CAUSE_METHOD_NAMES);
Throwable getCause(Throwable throwable)
get Cause
return getCause(throwable, CAUSE_METHOD_NAMES);
Throwable getCauseUsingWellKnownTypes(Throwable throwable)
get Cause Using Well Known Types
if (throwable instanceof SQLException) {
 return ((SQLException) throwable).getNextException();
} else if (throwable instanceof InvocationTargetException) {
 return ((InvocationTargetException) throwable).getTargetException();
} else {
 return null;
Throwable getCauseUsingWellKnownTypes(Throwable throwable)

Finds a Throwable for known types.

Uses instanceof checks to examine the exception, looking for well known types which could contain chained or wrapped exceptions.

if (throwable instanceof SQLException) {
 return ((SQLException) throwable).getNextException();
} else if (throwable instanceof InvocationTargetException) {
 return ((InvocationTargetException) throwable).getTargetException();
} else {
 return null;
Throwable getExceptionCauseUsingWellKnownTypes(final Throwable exception)
get Exception Cause Using Well Known Types
if (exception instanceof SQLException) {
 return ((SQLException) exception).getNextException();
} else if (exception instanceof InvocationTargetException) {
 return ((InvocationTargetException) exception).getTargetException();
} else {
 return null;
String getFullStackTrace(Throwable t)
get Full Stack Trace
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
Throwable[] ts = getThrowables(t);
for (Throwable t1 : ts) {
 t1.printStackTrace(pw);
 if (isNestedThrowable(t1)) {
 break;
return sw.getBuffer().toString();
Throwable getRootCause(Throwable throwable)

Walks through the exception chain to the last element -- the "root" of the tree -- using #getCause(Throwable) , and returns that exception.

Throwable cause = getCause(throwable);
if (cause != null) {
 throwable = cause;
 while ((throwable = getCause(throwable)) != null) {
 cause = throwable;
return cause;
...
String[] getRootCauseStackTrace(Throwable t)
Creates a compact stack trace for the root cause of the supplied throwable.
Throwable[] throwables = getThrowables(t);
int count = throwables.length;
ArrayList<String> frames = new ArrayList<String>();
List<String> nextTrace = getStackFrameList(throwables[count - 1]);
for (int i = count; --i >= 0;) {
 List<String> trace = nextTrace;
 if (i != 0) {
 nextTrace = getStackFrameList(throwables[i - 1]);
...
String[] getRootCauseStackTrace(Throwable throwable)

Creates a compact stack trace for the root cause of the supplied Throwable.

if (throwable == null) {
 return new String[0];
Throwable throwables[] = getThrowables(throwable);
int count = throwables.length;
ArrayList frames = new ArrayList();
List nextTrace = getStackFrameList(throwables[count - 1]);
for (int i = count; --i >= 0;) {
...


AltStyle によって変換されたページ (->オリジナル) /