static void loadTraceProperties() { // The following section is new // Load and apply the JDBC Server Trace value. String value = SystemProperties.getProperty(SystemProperties.TRACE_JDBC_SERVER); if (value != null) { try { JDBCServerTraceCategories_ = (new Integer(value)).intValue(); } catch (Exception e) { if (JDTrace.isTraceOn()) JDTrace.logInformation( "ServerTrace", "Value " + value + " for JDBCServerTrace is not valid."); } } }
/** * Returns part of the contents of the CLOB. * * @param position The position within the CLOB (1-based). * @param length The number of characters to return. * @return The contents. * @exception SQLException If the position is not valid, if the length is not valid, or an error * occurs. */ public String getSubString(long position, int length) throws SQLException { if (locator_ == null) // @free JDError.throwSQLException(this, JDError.EXC_FUNCTION_SEQUENCE); // @free synchronized (locator_) { int offset = (int) position - 1; if (offset < 0 || length < 0 || (offset > length())) { JDError.throwSQLException(this, JDError.EXC_ATTRIBUTE_VALUE_INVALID); } int lengthToUse = (int) length() - offset; if (lengthToUse < 0) return ""; if (lengthToUse > length) lengthToUse = length; // @xml4 if xml column, remove xml declaration via ConvTableReader if (isXML_) { ConvTableReader r = null; try { r = new ConvTableReader( new AS400JDBCInputStream(locator_), converter_.getCcsid(), converter_.bidiStringType_, isXML_); // @xml4 r.skip(offset); // @xml4 ConvTableReader will already have skipped XML header if column is // XML type return r.read(lengthToUse); // @xml4 } catch (Exception e) { JDError.throwSQLException(this, JDError.EXC_INTERNAL, e); return null; } finally { try { if (r != null) r.close(); } catch (Exception ee) { JDTrace.logException(this, "getSubString r.close() threw exception", ee); } } } DBLobData data = locator_.retrieveData(offset, lengthToUse); int actualLength = data.getLength(); return converter_.byteArrayToString(data.getRawBytes(), data.getOffset(), actualLength); } }