use of org.apache.derby.shared.common.error.StandardException in project derby by apache.
the class Util method javaException.
public static SQLException javaException(Throwable t) {
String name, msg;
msg = t.getMessage();
if (msg == null)
msg = "";
name = t.getClass().getName();
SQLException next = null;
Throwable cause = t.getCause();
if (cause != null) {
if (cause instanceof SQLException) {
next = (SQLException) cause;
} else if (cause instanceof StandardException) {
next = generateCsSQLException((StandardException) cause);
} else {
next = javaException(cause);
}
}
SQLException result = seeNextException(SQLState.JAVA_EXCEPTION, next, t, name, msg);
if (result.getErrorCode() >= logSeverityLevel) {
logSQLException(result);
}
return result;
}
use of org.apache.derby.shared.common.error.StandardException in project derby by apache.
the class XML method XMLQuery.
/**
* Evaluate the XML query expression contained within the received
* util object against this XML value and store the results into
* the received XMLDataValue "result" param (assuming "result" is
* non-null; else create a new XMLDataValue).
*
* @param sqlxUtil Contains SQL/XML objects and util methods that
* facilitate execution of XML-related operations
* @param result The result of a previous call to this method; null
* if not called yet.
* @return An XMLDataValue whose content corresponds to the serialized
* version of the results from evaluation of the query expression.
* Note: this XMLDataValue may not be storable into Derby XML
* columns.
* @exception StandardException thrown on error
*/
public XMLDataValue XMLQuery(SqlXmlUtil sqlxUtil, XMLDataValue result) throws StandardException {
if (this.isNull()) {
// per SQL/XML[2006] 6.17:GR.1.a.ii.1.
if (result == null)
result = (XMLDataValue) getNewNull();
else
result.setToNull();
return result;
}
try {
// Return an XML data value whose contents are the
// serialized version of the query results.
int[] xType = new int[1];
List itemRefs = sqlxUtil.evalXQExpression(this, true, xType);
if (result == null)
result = new XML();
String strResult = sqlxUtil.serializeToString(itemRefs, result);
result.setValue(new SQLChar(strResult));
// Now that we've set the result value, make sure
// to indicate what kind of XML value we have.
result.setXType(xType[0]);
// And finally we return the query result as an XML value.
return result;
} catch (StandardException se) {
// Just re-throw it.
throw se;
} catch (Throwable xe) {
/* Failed somewhere during evaluation of the XML query expression;
* turn error into a StandardException and throw it. Note: we
* catch "Throwable" here to catch as many Xalan-produced errors
* as possible in order to minimize the chance of an uncaught Xalan
* error (such as a NullPointerException) causing Derby to fail in
* a more serious way. In particular, an uncaught Java exception
* like NPE can result in Derby throwing "ERROR 40XT0: An internal
* error was identified by RawStore module" for all statements on
* the connection after the failure--which we clearly don't want.
* If we catch the error and wrap it, though, the statement will
* fail but Derby will continue to run as normal.
*/
throw StandardException.newException(SQLState.LANG_XML_QUERY_ERROR, xe, "XMLQUERY", xe.getMessage());
}
}
use of org.apache.derby.shared.common.error.StandardException in project derby by apache.
the class InterruptStatus method setInterrupted.
/**
* Make a note that this thread saw an interrupt. Thread's intr
* status flag is presumably off already, but we reset it here
* also. Use lcc if available, else thread local variable.
*/
public static void setInterrupted() {
LanguageConnectionContext lcc = null;
try {
lcc = (LanguageConnectionContext) getContextOrNull(LanguageConnectionContext.CONTEXT_ID);
} catch (ShutdownException e) {
// Ignore. Can happen when: a) background thread (RawStoreDaemon)
// is performing checkpointing and b) a user thread starts shutdown
// and interrupts the background thread. During recovery of the
// container we get here. DERBY-4920.
}
Thread.interrupted();
StandardException e = StandardException.newException(SQLState.CONN_INTERRUPT);
if (lcc != null) {
lcc.setInterruptedException(e);
} else {
exception.set(e);
}
}
use of org.apache.derby.shared.common.error.StandardException in project derby by apache.
the class EmbedCallableStatement method getBoolean.
/**
* @see CallableStatement#getBoolean
* @exception SQLException NoOutputParameters thrown.
*/
public boolean getBoolean(int parameterIndex) throws SQLException {
checkStatus();
try {
DataValueDescriptor param = getParms().getParameterForGet(parameterIndex - 1);
boolean v = param.getBoolean();
wasNull = (!v) && param.isNull();
return v;
} catch (StandardException e) {
throw EmbedResultSet.noStateChangeException(e);
}
}
use of org.apache.derby.shared.common.error.StandardException in project derby by apache.
the class EmbedCallableStatement method getShort.
/**
* @see CallableStatement#getShort
* @exception SQLException NoOutputParameters thrown.
*/
public short getShort(int parameterIndex) throws SQLException {
checkStatus();
try {
DataValueDescriptor param = getParms().getParameterForGet(parameterIndex - 1);
short s = param.getShort();
wasNull = (s == 0) && param.isNull();
return s;
} catch (StandardException e) {
throw EmbedResultSet.noStateChangeException(e);
}
}
Aggregations