List of usage examples for java.sql ResultSet getBlob
Blob getBlob(String columnLabel) throws SQLException;
ResultSet
object as a Blob
object in the Java programming language. From source file:us.daveread.basicquery.BasicQuery.java
/** * Get a field from the result set// w ww . jav a 2s . com * * @param result * The result set * @param columnNumber * The column to read data from * @param columnType * The data type for the column being read * * @return An object representing the data in the current row and selected * column */ private Object getResultField(ResultSet result, int columnNumber, int columnType) { Object value = null; try { switch (columnType) { case COLUMN_DATA_TYPE_INT: // Integer value = new Integer(result.getInt(columnNumber)); break; case COLUMN_DATA_TYPE_LONG: // Long value = new Long(result.getLong(columnNumber)); break; case COLUMN_DATA_TYPE_DOUBLE: // Double value = new Double(result.getDouble(columnNumber)); break; case COLUMN_DATA_TYPE_DATETIME: // Date/Time value = result.getTimestamp(columnNumber); break; case COLUMN_DATA_TYPE_BLOB: // BLOB try { value = result.getBlob(columnNumber); } catch (Throwable any) { LOGGER.error("Error retrieving BLOB field key", any); // Probably unsupported method (first found in a MySQL Driver) value = result.getString(columnNumber); } break; case 0: // Fall through to default default: value = result.getString(columnNumber); break; } } catch (Exception any) { LOGGER.error("Error Column[" + columnNumber + " Type[" + columnType + "]", any); messageOut(Resources.getString("errFailDataRead", "" + columnNumber, any.getMessage()), STYLE_YELLOW); try { value = result.getString(columnNumber); } catch (Throwable throwable) { LOGGER.error("Error Column[" + columnNumber + " Type[" + columnType + "]", any); messageOut(Resources.getString("errFailDataRead", "" + columnNumber, any.getMessage()), STYLE_RED); throw new IllegalStateException("Error Column[" + columnNumber + " Type[" + columnType + "]"); } } return value; }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BlobDefTable.java
protected MSSBamBlobDefBuff unpackBlobDefResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackBlobDefResultSetToBuff"; int idxcol = 1; String classCode = resultSet.getString(idxcol); idxcol++;/*from w w w . jav a 2 s. c o m*/ MSSBamBlobDefBuff buff; if (classCode.equals("BLB")) { buff = schema.getFactoryBlobDef().newBuff(); } else if (classCode.equals("TBLB")) { buff = schema.getFactoryTableBlob().newBuff(); } else if (classCode.equals("SBLB")) { buff = schema.getFactorySchemaBlob().newBuff(); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Unrecognized class code \"" + classCode + "\""); } buff.setRequiredId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalScopeId(null); } else { buff.setOptionalScopeId(colVal); } } idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalShortName(null); } else { buff.setOptionalShortName(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalLabel(null); } else { buff.setOptionalLabel(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalShortDescription(null); } else { buff.setOptionalShortDescription(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalDescription(null); } else { buff.setOptionalDescription(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalAuthorId(null); } else { buff.setOptionalAuthorId(colVal); } } idxcol++; buff.setRequiredValueContainerId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredIsNullable(resultSet.getBoolean(idxcol)); idxcol++; { boolean colVal = resultSet.getBoolean(idxcol); if (resultSet.wasNull()) { buff.setOptionalGenerateId(null); } else { buff.setOptionalGenerateId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalDataScopeId(null); } else { buff.setOptionalDataScopeId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalViewAccessSecurityId(null); } else { buff.setOptionalViewAccessSecurityId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalEditAccessSecurityId(null); } else { buff.setOptionalEditAccessSecurityId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalViewAccessFrequencyId(null); } else { buff.setOptionalViewAccessFrequencyId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalEditAccessFrequencyId(null); } else { buff.setOptionalEditAccessFrequencyId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalPrevId(null); } else { buff.setOptionalPrevId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalNextId(null); } else { buff.setOptionalNextId(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalDbName(null); } else { buff.setOptionalDbName(colVal); } } idxcol++; buff.setRequiredMaxLen(resultSet.getInt(idxcol)); idxcol++; { Blob binding = resultSet.getBlob(idxcol); if (resultSet.wasNull()) { buff.setOptionalInitValue(null); } else { long bindLen = binding.length(); if (bindLen > Integer.MAX_VALUE) { throw CFLib.getDefaultExceptionFactory().newArgumentOverflowException(getClass(), S_ProcName, idxcol, "InitValue", bindLen, (long) (Integer.MAX_VALUE)); } byte[] colVal = binding.getBytes(0, (int) bindLen); buff.setOptionalInitValue(colVal); } } idxcol++; { Blob binding = resultSet.getBlob(idxcol); if (resultSet.wasNull()) { buff.setOptionalDefaultValue(null); } else { long bindLen = binding.length(); if (bindLen > Integer.MAX_VALUE) { throw CFLib.getDefaultExceptionFactory().newArgumentOverflowException(getClass(), S_ProcName, idxcol, "DefaultValue", bindLen, (long) (Integer.MAX_VALUE)); } byte[] colVal = binding.getBytes(0, (int) bindLen); buff.setOptionalDefaultValue(colVal); } } idxcol++; { Blob binding = resultSet.getBlob(idxcol); if (resultSet.wasNull()) { buff.setOptionalNullValue(null); } else { long bindLen = binding.length(); if (bindLen > Integer.MAX_VALUE) { throw CFLib.getDefaultExceptionFactory().newArgumentOverflowException(getClass(), S_ProcName, idxcol, "NullValue", bindLen, (long) (Integer.MAX_VALUE)); } byte[] colVal = binding.getBytes(0, (int) bindLen); buff.setOptionalNullValue(colVal); } } idxcol++; { Blob binding = resultSet.getBlob(idxcol); if (resultSet.wasNull()) { buff.setOptionalUnknownValue(null); } else { long bindLen = binding.length(); if (bindLen > Integer.MAX_VALUE) { throw CFLib.getDefaultExceptionFactory().newArgumentOverflowException(getClass(), S_ProcName, idxcol, "UnknownValue", bindLen, (long) (Integer.MAX_VALUE)); } byte[] colVal = binding.getBytes(0, (int) bindLen); buff.setOptionalUnknownValue(colVal); } } idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:com.pari.nm.utils.db.InventoryDBHelper.java
public static String loadStartupConfig(int nodeId) { ResultSet rs = null; try {//from w w w . j a v a 2s.c o m rs = DBHelper.executeQuery("select config from node_current_config where id=" + nodeId + " AND conf_type=" + Constants.STARTUP_CONF); if (rs.next()) { byte b[] = null; if (ServerProperties.getInstance().isPostgres()) { b = rs.getBytes(1); } else { Blob blob = rs.getBlob(1); if (blob != null) { b = blob.getBytes(1, (int) blob.length()); } } if (b != null) { return CompressionUtils.getUncompressedString(b); } } } catch (Exception ex) { logger.error("Exception while loading startup config for device: " + nodeId, ex); } finally { if (rs != null) { try { rs.close(); } catch (Exception ex) { } } } return ""; }
From source file:com.pari.nm.utils.db.InventoryDBHelper.java
public static String getShowCli(int nodeId, String cli) { ResultSet rs = null; Connection c = null;//from w w w .j a v a 2s . co m PreparedStatement ps = null; String sql = "select out_put from show_commands_new where device_id=? and cli=?"; try { c = DBHelper.getConnection(); ps = c.prepareStatement(sql); ps.setInt(1, nodeId); ps.setString(2, cli); rs = ps.executeQuery(); byte b[] = null; if (rs != null && rs.next()) { if (ServerProperties.getInstance().isPostgres()) { b = rs.getBytes(1); } else { Blob blob = rs.getBlob(1); if (blob != null) { b = blob.getBytes(1, (int) blob.length()); } } if (b != null) { return CompressionUtils.getUncompressedString(b); } } } catch (Exception ee) { logger.warn("Error while getting show cli for the node = " + nodeId + " and cli = " + cli, ee); } finally { if (rs != null) { try { rs.close(); } catch (Exception ex) { } } if (ps != null) { try { ps.close(); } catch (Exception ee) { } } if (c != null) { try { DBHelper.releaseConnection(c); } catch (Exception ex) { } } } return ""; }
From source file:com.pari.nm.utils.db.InventoryDBHelper.java
public static String loadRunningConfig(int nodeId) { ResultSet rs = null; Connection c = null;/*from ww w. j a v a2 s.com*/ PreparedStatement ps = null; try { c = DBHelper.getConnection(); ps = c.prepareStatement( "select config from node_current_config where id= ? AND conf_type=" + Constants.RUN_CONF); // rs = // DBHelper.executeQuery("select config from node_current_config where id=" // + nodeId + // " AND conf_type=" // + Constants.STARTUP_CONF); ps.setInt(1, nodeId); rs = ps.executeQuery(); if (rs.next()) { byte b[] = null; if (ServerProperties.getInstance().isPostgres()) { b = rs.getBytes(1); } else { Blob blob = rs.getBlob(1); if (blob != null) { b = blob.getBytes(1, (int) blob.length()); } } if (b != null) { return CompressionUtils.getUncompressedString(b); } } } catch (Exception ex) { logger.error("Exception while loading running config for device: " + nodeId, ex); } finally { if (rs != null) { try { rs.close(); } catch (Exception ex) { } } if (ps != null) { try { ps.close(); } catch (Exception e) { } } DBHelper.releaseConnection(c); } return ""; }
From source file:it.greenvulcano.gvesb.datahandling.dbo.utils.ExtendedRowSetBuilder.java
public int build(Document doc, String id, ResultSet rs, Set<Integer> keyField, Map<String, FieldFormatter> fieldNameToFormatter, Map<String, FieldFormatter> fieldIdToFormatter) throws Exception { if (rs == null) { return 0; }/* w w w . java 2s. co m*/ int rowCounter = 0; Element docRoot = doc.getDocumentElement(); ResultSetMetaData metadata = rs.getMetaData(); buildFormatterAndNamesArray(metadata, fieldNameToFormatter, fieldIdToFormatter); boolean noKey = ((keyField == null) || keyField.isEmpty()); boolean isKeyCol = false; boolean isNull = false; Element data = null; Element row = null; Element col = null; Text text = null; String textVal = null; String precKey = null; String colKey = null; Map<String, Element> keyCols = new TreeMap<String, Element>(); while (rs.next()) { if (rowCounter % 10 == 0) { ThreadUtils.checkInterrupted(getClass().getSimpleName(), name, logger); } row = parser.createElementNS(doc, AbstractDBO.ROW_NAME, NS); parser.setAttribute(row, AbstractDBO.ID_NAME, id); for (int j = 1; j <= metadata.getColumnCount(); j++) { FieldFormatter fF = fFormatters[j]; String colName = colNames[j]; isKeyCol = (!noKey && keyField.contains(new Integer(j))); isNull = false; col = parser.createElementNS(doc, colName, NS); if (isKeyCol) { parser.setAttribute(col, AbstractDBO.ID_NAME, String.valueOf(j)); } switch (metadata.getColumnType(j)) { case Types.DATE: case Types.TIME: case Types.TIMESTAMP: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.TIMESTAMP_TYPE); Timestamp dateVal = rs.getTimestamp(j); isNull = dateVal == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { parser.setAttribute(col, AbstractDBO.FORMAT_NAME, AbstractDBO.DEFAULT_DATE_FORMAT); textVal = ""; } else { if (fF != null) { parser.setAttribute(col, AbstractDBO.FORMAT_NAME, fF.getDateFormat()); textVal = fF.formatDate(dateVal); } else { parser.setAttribute(col, AbstractDBO.FORMAT_NAME, AbstractDBO.DEFAULT_DATE_FORMAT); textVal = dateFormatter.format(dateVal); } } } break; case Types.DOUBLE: case Types.FLOAT: case Types.REAL: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE); float numVal = rs.getFloat(j); parser.setAttribute(col, AbstractDBO.NULL_NAME, "false"); if (fF != null) { parser.setAttribute(col, AbstractDBO.FORMAT_NAME, fF.getNumberFormat()); parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, fF.getGroupSeparator()); parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, fF.getDecSeparator()); textVal = fF.formatNumber(numVal); } else { parser.setAttribute(col, AbstractDBO.FORMAT_NAME, numberFormat); parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, groupSeparator); parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, decSeparator); textVal = numberFormatter.format(numVal); } } break; case Types.BIGINT: case Types.INTEGER: case Types.NUMERIC: case Types.SMALLINT: case Types.TINYINT: { BigDecimal bigdecimal = rs.getBigDecimal(j); isNull = bigdecimal == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { if (metadata.getScale(j) > 0) { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE); } else { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.NUMERIC_TYPE); } textVal = ""; } else { if (fF != null) { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE); parser.setAttribute(col, AbstractDBO.FORMAT_NAME, fF.getNumberFormat()); parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, fF.getGroupSeparator()); parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, fF.getDecSeparator()); textVal = fF.formatNumber(bigdecimal); } else if (metadata.getScale(j) > 0) { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE); parser.setAttribute(col, AbstractDBO.FORMAT_NAME, numberFormat); parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, groupSeparator); parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, decSeparator); textVal = numberFormatter.format(bigdecimal); } else { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.NUMERIC_TYPE); textVal = bigdecimal.toString(); } } } break; case Types.NCHAR: case Types.NVARCHAR: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.NSTRING_TYPE); textVal = rs.getNString(j); isNull = textVal == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } } break; case Types.CHAR: case Types.VARCHAR: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.STRING_TYPE); textVal = rs.getString(j); isNull = textVal == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } } break; case Types.NCLOB: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.LONG_NSTRING_TYPE); NClob clob = rs.getNClob(j); isNull = clob == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } else { Reader is = clob.getCharacterStream(); StringWriter str = new StringWriter(); IOUtils.copy(is, str); is.close(); textVal = str.toString(); } } break; case Types.CLOB: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.LONG_STRING_TYPE); Clob clob = rs.getClob(j); isNull = clob == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } else { Reader is = clob.getCharacterStream(); StringWriter str = new StringWriter(); IOUtils.copy(is, str); is.close(); textVal = str.toString(); } } break; case Types.BLOB: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.BASE64_TYPE); Blob blob = rs.getBlob(j); isNull = blob == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } else { InputStream is = blob.getBinaryStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(is, baos); is.close(); try { byte[] buffer = Arrays.copyOf(baos.toByteArray(), (int) blob.length()); textVal = Base64.getEncoder().encodeToString(buffer); } catch (SQLFeatureNotSupportedException exc) { textVal = Base64.getEncoder().encodeToString(baos.toByteArray()); } } } break; default: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.DEFAULT_TYPE); textVal = rs.getString(j); isNull = textVal == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } } } if (textVal != null) { text = doc.createTextNode(textVal); col.appendChild(text); } if (isKeyCol) { if (textVal != null) { if (colKey == null) { colKey = textVal; } else { colKey += "##" + textVal; } keyCols.put(String.valueOf(j), col); } } else { row.appendChild(col); } } if (noKey) { if (data == null) { data = parser.createElementNS(doc, AbstractDBO.DATA_NAME, NS); parser.setAttribute(data, AbstractDBO.ID_NAME, id); } } else if ((colKey != null) && !colKey.equals(precKey)) { if (data != null) { docRoot.appendChild(data); } data = parser.createElementNS(doc, AbstractDBO.DATA_NAME, NS); parser.setAttribute(data, AbstractDBO.ID_NAME, id); Element key = parser.createElementNS(doc, AbstractDBO.KEY_NAME, NS); data.appendChild(key); for (Entry<String, Element> keyColsEntry : keyCols.entrySet()) { key.appendChild(keyColsEntry.getValue()); } keyCols.clear(); precKey = colKey; } colKey = null; data.appendChild(row); rowCounter++; } if (data != null) { docRoot.appendChild(data); } return rowCounter; }
From source file:it.greenvulcano.gvesb.datahandling.dbo.utils.StandardRowSetBuilder.java
public int build(Document doc, String id, ResultSet rs, Set<Integer> keyField, Map<String, FieldFormatter> fieldNameToFormatter, Map<String, FieldFormatter> fieldIdToFormatter) throws Exception { if (rs == null) { return 0; }/*from w w w . jav a 2 s . co m*/ int rowCounter = 0; Element docRoot = doc.getDocumentElement(); ResultSetMetaData metadata = rs.getMetaData(); FieldFormatter[] fFormatters = buildFormatterArray(metadata, fieldNameToFormatter, fieldIdToFormatter); boolean noKey = ((keyField == null) || keyField.isEmpty()); //boolean isNull = false; Element data = null; Element row = null; Element col = null; Text text = null; String textVal = null; String precKey = null; String colKey = null; Map<String, String> keyAttr = new HashMap<String, String>(); while (rs.next()) { if (rowCounter % 10 == 0) { ThreadUtils.checkInterrupted(getClass().getSimpleName(), name, logger); } row = parser.createElement(doc, AbstractDBO.ROW_NAME); parser.setAttribute(row, AbstractDBO.ID_NAME, id); for (int j = 1; j <= metadata.getColumnCount(); j++) { FieldFormatter fF = fFormatters[j]; //isNull = false; col = parser.createElement(doc, AbstractDBO.COL_NAME); switch (metadata.getColumnType(j)) { case Types.DATE: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.DATE_TYPE); java.sql.Date dateVal = rs.getDate(j); textVal = processDateTime(col, fF, dateVal, AbstractDBO.DEFAULT_DATE_FORMAT); } break; case Types.TIME: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.TIME_TYPE); java.sql.Time dateVal = rs.getTime(j); textVal = processDateTime(col, fF, dateVal, AbstractDBO.DEFAULT_TIME_FORMAT); } break; case Types.TIMESTAMP: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.TIMESTAMP_TYPE); Timestamp dateVal = rs.getTimestamp(j); textVal = processDateTime(col, fF, dateVal, AbstractDBO.DEFAULT_DATE_FORMAT); } break; case Types.DOUBLE: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE); double numVal = rs.getDouble(j); textVal = processDouble(col, fF, numVal); } break; case Types.FLOAT: case Types.REAL: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.FLOAT_TYPE); float numVal = rs.getFloat(j); textVal = processDouble(col, fF, numVal); } break; case Types.BIGINT: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.BIGINT_TYPE); long numVal = rs.getLong(j); parser.setAttribute(col, AbstractDBO.NULL_NAME, "false"); textVal = String.valueOf(numVal); } break; case Types.INTEGER: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.INTEGER_TYPE); int numVal = rs.getInt(j); parser.setAttribute(col, AbstractDBO.NULL_NAME, "false"); textVal = String.valueOf(numVal); } break; case Types.SMALLINT: case Types.TINYINT: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.SMALLINT_TYPE); short numVal = rs.getShort(j); parser.setAttribute(col, AbstractDBO.NULL_NAME, "false"); textVal = String.valueOf(numVal); } break; case Types.NUMERIC: case Types.DECIMAL: { BigDecimal bigdecimal = rs.getBigDecimal(j); boolean isNull = bigdecimal == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { if (metadata.getScale(j) > 0) { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.DECIMAL_TYPE); } else { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.NUMERIC_TYPE); } textVal = ""; } else { if (fF != null) { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.DECIMAL_TYPE); parser.setAttribute(col, AbstractDBO.FORMAT_NAME, fF.getNumberFormat()); parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, fF.getGroupSeparator()); parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, fF.getDecSeparator()); textVal = fF.formatNumber(bigdecimal); } else if (metadata.getScale(j) > 0) { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.DECIMAL_TYPE); parser.setAttribute(col, AbstractDBO.FORMAT_NAME, numberFormat); parser.setAttribute(col, AbstractDBO.GRP_SEPARATOR_NAME, groupSeparator); parser.setAttribute(col, AbstractDBO.DEC_SEPARATOR_NAME, decSeparator); textVal = numberFormatter.format(bigdecimal); } else { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.NUMERIC_TYPE); textVal = bigdecimal.toString(); } } } break; case Types.BOOLEAN: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.BOOLEAN_TYPE); boolean bVal = rs.getBoolean(j); parser.setAttribute(col, AbstractDBO.NULL_NAME, "false"); textVal = String.valueOf(bVal); } break; case Types.SQLXML: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.XML_TYPE); SQLXML xml = rs.getSQLXML(j); boolean isNull = xml == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } else { textVal = xml.getString(); } } break; case Types.NCHAR: case Types.NVARCHAR: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.NSTRING_TYPE); textVal = rs.getNString(j); if (textVal == null) { textVal = ""; } } break; case Types.CHAR: case Types.VARCHAR: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.STRING_TYPE); textVal = rs.getString(j); boolean isNull = textVal == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } } break; case Types.NCLOB: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.LONG_NSTRING_TYPE); NClob clob = rs.getNClob(j); if (clob != null) { Reader is = clob.getCharacterStream(); StringWriter str = new StringWriter(); IOUtils.copy(is, str); is.close(); textVal = str.toString(); } else { textVal = ""; } } break; case Types.CLOB: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.LONG_STRING_TYPE); Clob clob = rs.getClob(j); if (clob != null) { Reader is = clob.getCharacterStream(); StringWriter str = new StringWriter(); IOUtils.copy(is, str); is.close(); textVal = str.toString(); } else { textVal = ""; } } break; case Types.BLOB: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.BASE64_TYPE); Blob blob = rs.getBlob(j); boolean isNull = blob == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } else { InputStream is = blob.getBinaryStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(is, baos); is.close(); try { byte[] buffer = Arrays.copyOf(baos.toByteArray(), (int) blob.length()); textVal = Base64.getEncoder().encodeToString(buffer); } catch (SQLFeatureNotSupportedException exc) { textVal = Base64.getEncoder().encodeToString(baos.toByteArray()); } } } break; default: { parser.setAttribute(col, AbstractDBO.TYPE_NAME, AbstractDBO.DEFAULT_TYPE); textVal = rs.getString(j); boolean isNull = textVal == null; parser.setAttribute(col, AbstractDBO.NULL_NAME, String.valueOf(isNull)); if (isNull) { textVal = ""; } } } if (textVal != null) { text = doc.createTextNode(textVal); col.appendChild(text); } if (!noKey && keyField.contains(new Integer(j))) { if (textVal != null) { if (colKey == null) { colKey = textVal; } else { colKey += "##" + textVal; } keyAttr.put("key_" + j, textVal); } } else { row.appendChild(col); } } if (noKey) { if (data == null) { data = parser.createElement(doc, AbstractDBO.DATA_NAME); parser.setAttribute(data, AbstractDBO.ID_NAME, id); } } else if ((colKey != null) && !colKey.equals(precKey)) { if (data != null) { docRoot.appendChild(data); } data = parser.createElement(doc, AbstractDBO.DATA_NAME); parser.setAttribute(data, AbstractDBO.ID_NAME, id); for (Entry<String, String> keyAttrEntry : keyAttr.entrySet()) { parser.setAttribute(data, keyAttrEntry.getKey(), keyAttrEntry.getValue()); } keyAttr.clear(); precKey = colKey; } colKey = null; data.appendChild(row); rowCounter++; } if (data != null) { docRoot.appendChild(data); } return rowCounter; }
From source file:com.pari.nm.utils.db.ReportDBHelper.java
public static ServiceContainerImpl getDataFromTempTable(String reportId, String sessionId, int start, int pageLength, ServiceDescriptor descriptor, TableDefinition tableDef, ArrayList<String> childColumnsList, Map<String, String> mapOfConditions, Map<String, String> sortingFilters, List<ColumnLevelFilter> columnLevelFilters, String uniqueColumn) throws Exception { Connection connection = null; Statement statement = null;//from w w w. java2 s. c om ResultSet rs = null; String tblName = getTempPaginationTblName(reportId, sessionId); if (tblName == null) { throw new Exception("No Table Exist with ReportId:\t" + reportId + " and SessionId:\t" + sessionId); } logger.info("Getting Data from the following Table Name:\t" + tblName); ServiceContainerImpl sImpl = new ServiceContainerImpl(descriptor, null); Def[] childDefArr = descriptor.getAllChildRefs(); ArrayList<String> childIdentifersList = null; String childIdentifierName = null; if (childDefArr != null && childDefArr.length > 0) { childIdentifersList = new ArrayList<String>(); for (Def def : childDefArr) { childIdentifierName = def.getName(); childIdentifersList.add(childIdentifierName); } } connection = DBHelper.getConnection(); if (connection == null) { logger.info("Unable to get Connection."); return null; } // StringBuffer sb = getQuery(reportId, start, pageLength, tblName, mapOfConditions, tableDef, sortingFilters, // columnLevelFilters, uniqueColumn); // StringBuffer sb = getQuery(reportId, start, pageLength, tblName, mapOfConditions, tableDef, sortingFilters); String childTblName = getTempPaginationTblName(reportId, sessionId, childIdentifierName); // Create child columns list from child table definition object instead of using // childColumnsList which incorrectly includes all child columns names. So previous // implementation bombs when more than one child is present. List<String> childColList = new ArrayList<>(); if (tableDef != null) { TableDefinition childTable = tableDef.getChildTableById(childIdentifierName); if (childTable != null) { ColumnDefinition[] columnDefs = childTable.getColumnDefs(); for (ColumnDefinition columnDef : columnDefs) { childColList.add(columnDef.getId()); } } } StringBuffer sb = getQuery(reportId, start, pageLength, tblName, mapOfConditions, tableDef, sortingFilters, childTblName, childColList, columnLevelFilters, uniqueColumn); try { statement = connection.createStatement(); rs = statement.executeQuery(sb.toString()); ArrayList<String> columnList = null; if (reportId.equals("extended_device_attributes_report")) { columnList = getColumnInfo(tableDef); } else { columnList = getColumnInfo(descriptor); } while ((rs != null) && rs.next()) { ServiceImpl service = new ServiceImpl(descriptor); if (columnList != null) { for (String column : uniqueColumn != null ? new String[] { uniqueColumn } : columnList.toArray(new String[] {})) { // Need to add Code to update for Child Tables: // if (column.equalsIgnoreCase("JobRunSummary")) if (childIdentifersList != null && childIdentifersList.contains(column)) { HashMap<String, String> parentKeyValueMap = new HashMap<String, String>(); AttrDef[] attrDefArr = descriptor.getKeys(); if (attrDefArr != null) { for (AttrDef attDef : attrDefArr) { String key = attDef.getName(); String value = rs.getString(attDef.getName()); parentKeyValueMap.put(key, value); } } // we need to populate Child Table Information // 1. get ChildTableName // String childInfoName = "JobRunSummary"; String childInfoName = childIdentifierName; // String childTblName = getTempPaginationTblName(reportId, sessionId, childInfoName); childTblName = getTempPaginationTblName(reportId, sessionId, column); if (childTblName == null) { throw new Exception("No Table Exist with ReportId:\t" + reportId + "and SessionId:\t" + sessionId + " and ChildTblName:\t" + childInfoName); } logger.info("Getting Data from the following Table Name:\t" + childTblName); // Create child columns list from child table definition object instead of using // childColumnsList which incorrectly includes all child columns names. So previous // implementation bombs when more than one child is present. if (tableDef != null) { TableDefinition childTable = tableDef.getChildTableById(column); ColumnDefinition[] columnDefs = childTable.getColumnDefs(); List<String> childColumns = new ArrayList<>(); for (ColumnDefinition columnDef : columnDefs) { childColumns.add(columnDef.getId()); } ServiceContainerImpl servImpl = getChildTblInformation1(childTblName, parentKeyValueMap, sImpl, childColumns); logger.info("========================================================" + servImpl.size()); if (servImpl != null && servImpl.size() > 0) { service.setAttribute(column, servImpl); } } } else if (column.equalsIgnoreCase("RowId")) { // In ProfileRunSummary Report, column named RowId, it is conflicting with RowId in Oracle, // so appended 123 to RowId. service.setAttribute("RowId", rs.getString(column + "123")); } else if (column.equalsIgnoreCase("User")) { // In Unmanaged Device Report, column named User, it is conflicting with User in Oracle, so // appended 123 to User. service.setAttribute("User", rs.getString(column + "123")); } else if (column.equalsIgnoreCase("Comment")) { // In My Pending Approvals Report, column named Comment, it is conflicting with Comment in // Oracle, so appended 123 to Comment. service.setAttribute("Comment", rs.getString(column + "123")); } else if (column.equalsIgnoreCase("Size")) { // Manage script repository export contains size, which is conflicting with Oracle reserved // word, and this column changed to 'size123' service.setAttribute("Size", rs.getString(column + "123")); } else if (column.equalsIgnoreCase("Timestamp")) { service.setAttribute(column, rs.getString(column + "123")); } else if (column.equalsIgnoreCase("ChildrenCount")) { service.setAttribute("ChildrenCount", rs.getInt("childCount")); } else if ((!(reportId.equals("swim_install_analysis_report"))) && column.equalsIgnoreCase("Details")) { String columnName = getRenderColumnName(column, tableDef); columnName = (null == columnName) ? column : columnName; String value = CompressionUtils.getUncompressedDecoded(rs.getString(columnName)); service.setAttribute(column, value); } else if (column.equalsIgnoreCase("ViolationDetails")) { Blob blob = rs.getBlob(column); byte b[] = null; if (blob != null) { b = blob.getBytes(1, (int) blob.length()); } if (b != null) { BASE64Encoder encoder = new BASE64Encoder(); service.setAttribute(column, encoder.encode(b)); } } else { String columnName = getRenderColumnName(column, tableDef); columnName = (null == columnName) ? column : columnName; service.setAttribute(column, rs.getString(columnName)); } } } sImpl.addService(service); service.setServiceContainer(sImpl); } } catch (Exception ex) { logger.error("Error while creating customer upload details report.", ex); try { throw ex; } catch (Exception e) { e.printStackTrace(); } } finally { try { if (rs != null) { rs.close(); } } catch (Exception ee) { } try { if (statement != null) { statement.close(); } } catch (SQLException sqlEx) { logger.error("Exception while closing statement", sqlEx); } DBHelper.releaseConnection(connection); } return sImpl; }
From source file:com.github.woonsan.jdbc.jcr.impl.JcrJdbcResultSetTest.java
@Test public void testUnsupportedOperations() throws Exception { Statement statement = getConnection().createStatement(); ResultSet rs = statement.executeQuery(SQL_EMPS); try {//from ww w. j a v a 2 s . c om rs.getWarnings(); fail(); } catch (UnsupportedOperationException ignore) { } try { rs.clearWarnings(); fail(); } catch (UnsupportedOperationException ignore) { } try { rs.getCursorName(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getObject(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getObject("ename"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.isLast(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.beforeFirst(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.afterLast(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.first(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.last(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.absolute(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.relative(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.previous(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.moveToCurrentRow(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNull(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNull("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBoolean(1, true); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBoolean("col1", true); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateByte(1, (byte) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateByte("col1", (byte) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateShort(1, (short) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateShort("col1", (short) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateInt(1, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateInt("col1", 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateLong(1, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateLong("col1", (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateFloat(1, (float) 0.1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateFloat("col1", (float) 0.1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateDouble(1, 0.1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateDouble("col1", 0.1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBigDecimal(1, new BigDecimal("100000000")); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBigDecimal("col1", new BigDecimal("100000000")); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateString(1, "Unknown"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateString("col1", "Unknown"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBytes(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBytes("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateDate(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateDate("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateTime(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateTime("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateTimestamp(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateTimestamp("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream(1, null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream("col1", null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream(1, null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream("col1", null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream(1, null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream("col1", null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateObject(1, null, 1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateObject("col1", null, 1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateObject(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateObject("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.insertRow(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateRow(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.deleteRow(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.refreshRow(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.cancelRowUpdates(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.moveToInsertRow(); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getObject(1, (Map<String, Class<?>>) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getObject("col1", (Map<String, Class<?>>) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getRef(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getRef("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getBlob(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getBlob("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getClob(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getClob("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getURL(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getURL("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateRef(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateRef("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBlob(1, (Blob) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBlob("col1", (Blob) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateClob(1, (Clob) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateClob("col1", (Clob) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateArray(1, (Array) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateArray("col1", (Array) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getRowId(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getRowId("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateRowId(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateRowId("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNString(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNString("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNClob(1, (NClob) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNClob("col1", (NClob) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getNClob(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getNClob("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getSQLXML(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getSQLXML("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateSQLXML(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateSQLXML("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getNString(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getNString("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getNCharacterStream(1); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getNCharacterStream("col1"); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNCharacterStream(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNCharacterStream(1, null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNCharacterStream("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNCharacterStream("col1", null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream(1, null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream("col1", null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream(1, null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream("col1", null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream(1, null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream("col1", null, (long) 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBlob(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBlob("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateClob(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateClob("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNClob(1, null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNClob("col1", null, 0); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNCharacterStream(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNCharacterStream("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateAsciiStream("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBinaryStream("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream(1, null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateCharacterStream("col1", null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBlob(1, (InputStream) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateBlob("col1", (InputStream) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateClob(1, (Reader) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateClob("col1", (Reader) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNClob(1, (Reader) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.updateNClob("col1", (Reader) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getObject(1, (Class<?>) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } try { rs.getObject("col1", (Class<?>) null); fail(); } catch (SQLFeatureNotSupportedException ignore) { } rs.close(); assertTrue(rs.isClosed()); statement.close(); assertTrue(statement.isClosed()); }