List of usage examples for java.sql ResultSet getClob
Clob getClob(String columnLabel) throws SQLException;
ResultSet
object as a Clob
object in the Java programming language. From source file:edu.harvard.i2b2.ontology.dao.ConceptDao.java
public List findRootCategories(final GetCategoriesType returnType, final ProjectType projectInfo, final DBInfoType dbInfo) throws I2B2Exception, I2B2DAOException { // find return parameters String parameters = CAT_DEFAULT; if (returnType.getType().equals("limited")) { parameters = CAT_LIMITED;//from w ww .java 2 s. com } else if (returnType.getType().equals("core")) { parameters = CAT_CORE; } /* else if (returnType.getType().equals("all")){ parameters = ALL; } */ String metadataSchema = dbInfo.getDb_fullSchema(); setDataSource(dbInfo.getDb_dataSource()); // First step is to call PM to see what roles user belongs to. if (projectInfo.getRole().size() == 0) { log.error("no role found for this user in project: " + projectInfo.getName()); I2B2Exception e = new I2B2Exception("No role found for user"); throw e; } Boolean protectedAccess = false; Iterator it = projectInfo.getRole().iterator(); while (it.hasNext()) { String role = (String) it.next(); if (role.toUpperCase().equals("DATA_PROT")) { protectedAccess = true; break; } } final boolean obfuscatedUserFlag = Roles.getInstance().isRoleOfuscated(projectInfo); ParameterizedRowMapper<ConceptType> mapper = new ParameterizedRowMapper<ConceptType>() { public ConceptType mapRow(ResultSet rs, int rowNum) throws SQLException { ConceptType child = new ConceptType(); //TODO fix this for all child.setKey("\\\\" + rs.getString("c_table_cd") + rs.getString("c_fullname")); child.setName(rs.getString("c_name")); if (returnType.getType().equals("limited")) { child.setBasecode(rs.getString("c_basecode")); child.setLevel(rs.getInt("c_hlevel")); child.setSynonymCd(rs.getString("c_synonym_cd")); child.setVisualattributes(rs.getString("c_visualattributes")); child.setTooltip(rs.getString("c_tooltip")); child.setValuetypeCd(rs.getString("valuetype_cd")); } else if (returnType.getType().equals("core")) { child.setBasecode(rs.getString("c_basecode")); child.setLevel(rs.getInt("c_hlevel")); child.setSynonymCd(rs.getString("c_synonym_cd")); child.setVisualattributes(rs.getString("c_visualattributes")); Integer totalNum = rs.getInt("c_totalnum"); boolean nullFlag = rs.wasNull(); if (nullFlag) { log.debug("null in totalnum flag "); } else { log.debug("not null in totalnum flag "); } if (rs.getString("c_totalnum") == null) { log.debug("null in totalnum flag using getString method"); } else { log.debug("not null in totalnum flag using getString method [" + rs.getString("c_totalnum") + "]"); } if (obfuscatedUserFlag == false && nullFlag == false) { child.setTotalnum(totalNum); } child.setFacttablecolumn(rs.getString("c_facttablecolumn")); child.setTablename(rs.getString("c_dimtablename")); child.setColumnname(rs.getString("c_columnname")); child.setColumndatatype(rs.getString("c_columndatatype")); child.setOperator(rs.getString("c_operator")); child.setDimcode(rs.getString("c_dimcode")); child.setTooltip(rs.getString("c_tooltip")); child.setValuetypeCd(rs.getString("valuetype_cd")); } return child; } }; List queryResult = null; if (!protectedAccess) { String categoriesSql = "select c_table_cd, " + parameters + " from " + metadataSchema + "table_access where c_protected_access = ? "; String hidden = ""; if (returnType.isHiddens() == false) hidden = " and c_visualattributes not like '_H%'"; String synonym = ""; if (returnType.isSynonyms() == false) synonym = " and c_synonym_cd = 'N'"; categoriesSql = categoriesSql + hidden + synonym + "order by upper(c_name)"; log.debug(categoriesSql); try { queryResult = jt.query(categoriesSql, mapper, "N"); } catch (DataAccessException e) { log.error(e.getMessage()); throw new I2B2DAOException("Database error"); } } else { String categoriesSql = "select c_table_cd, " + parameters + " from " + metadataSchema + "table_access "; String hidden = ""; if (returnType.isHiddens() == false) hidden = " where c_visualattributes not like '_H%'"; String synonym = ""; if (returnType.isSynonyms() == false) synonym = " c_synonym_cd = 'N'"; String whereClause = hidden; if ((whereClause.length() > 2) && (synonym.length() > 2)) whereClause = whereClause + " and " + synonym; else if (synonym.length() > 2) whereClause = " where " + synonym; categoriesSql = categoriesSql + whereClause + " order by upper(c_name)"; log.debug(categoriesSql); try { queryResult = jt.query(categoriesSql, mapper); } catch (DataAccessException e) { log.error(e.getMessage()); throw new I2B2DAOException("Database Error"); } } log.debug("result size = " + queryResult.size()); if (returnType.isBlob() == true && queryResult != null) { Iterator itr = queryResult.iterator(); while (itr.hasNext()) { ConceptType child = (ConceptType) itr.next(); String clobSql = "select c_metadataxml, c_comment from " + metadataSchema + "table_access where c_table_cd = ?"; ParameterizedRowMapper<ConceptType> map = new ParameterizedRowMapper<ConceptType>() { public ConceptType mapRow(ResultSet rs, int rowNum) throws SQLException { ConceptType concept = new ConceptType(); // ResultSetMetaData rsmd = rs.getMetaData(); // rsmd.get String c_xml = null; try { if (dbInfo.getDb_serverType().equals("POSTGRESQL")) c_xml = rs.getString("c_metadataxml"); else if (rs.getClob("c_metadataxml") != null) c_xml = JDBCUtil.getClobString(rs.getClob("c_metadataxml")); } catch (IOException e) { log.error(e.getMessage()); concept.setMetadataxml(null); } if (c_xml == null) { concept.setMetadataxml(null); } else { if ((c_xml != null) && (c_xml.trim().length() > 0) && (!c_xml.equals("(null)"))) { SAXBuilder parser = new SAXBuilder(); java.io.StringReader xmlStringReader = new java.io.StringReader(c_xml); Element rootElement = null; try { org.jdom.Document metadataDoc = parser.build(xmlStringReader); org.jdom.output.DOMOutputter out = new DOMOutputter(); Document doc = out.output(metadataDoc); rootElement = doc.getDocumentElement(); } catch (JDOMException e) { log.error(e.getMessage()); concept.setMetadataxml(null); } catch (IOException e) { log.error(e.getMessage()); concept.setMetadataxml(null); } if (rootElement != null) { XmlValueType xml = new XmlValueType(); xml.getAny().add(rootElement); concept.setMetadataxml(xml); } } else { concept.setMetadataxml(null); } } try { if (dbInfo.getDb_serverType().equals("POSTGRESQL")) { concept.setComment(rs.getString("c_comment")); } else if (rs.getClob("c_comment") != null) { concept.setComment(JDBCUtil.getClobString(rs.getClob("c_comment"))); } } catch (Exception e) { concept.setComment(null); } return concept; } }; List clobResult = null; try { clobResult = jt.query(clobSql, map, StringUtil.getTableCd(child.getKey())); } catch (DataAccessException e) { log.error(e.getMessage()); throw new I2B2DAOException("Database Error"); } if (clobResult != null) { child.setMetadataxml(((ConceptType) (clobResult.get(0))).getMetadataxml()); child.setComment(((ConceptType) (clobResult.get(0))).getComment()); } else { child.setMetadataxml(null); child.setComment(null); } } } return queryResult; }
From source file:edu.harvard.i2b2.ontology.dao.GetCodeInfoDao.java
public List findCodeInfo(final VocabRequestType vocabType, final List categories, ProjectType projectInfo) throws DataAccessException, I2B2Exception { DataSource ds = null;//from w w w . j a va 2 s. com try { ds = OntologyUtil.getInstance().getDataSource("java:OntologyLocalDS"); } catch (I2B2Exception e2) { log.error(e2.getMessage()); throw e2; } SimpleJdbcTemplate jt = new SimpleJdbcTemplate(ds); // find return parameters String parameters = DEFAULT; if (vocabType.getType().equals("core")) { parameters = CORE; } else if (vocabType.getType().equals("all")) { parameters = ALL; } if (vocabType.isBlob() == true) parameters = parameters + BLOB; //extract table code String tableCd = vocabType.getCategory(); // log.info(tableCd); // table code to table name conversion // Get metadata schema name from properties file. String metadataSchema = ""; try { metadataSchema = OntologyUtil.getInstance().getMetaDataSchemaName(); } catch (I2B2Exception e1) { log.error(e1.getMessage()); throw e1; } List tableNames = null; if (tableCd != null) { // table code to table name conversion String tableSql = "select distinct(c_table_name) from " + metadataSchema + "table_access where c_table_cd = ? "; ParameterizedRowMapper<String> map = new ParameterizedRowMapper<String>() { public String mapRow(ResultSet rs, int rowNum) throws SQLException { String name = (rs.getString("c_table_name")); return name; } }; tableNames = jt.query(tableSql, map, tableCd); } else { // tableCd is null, so query all tables user has access to String whereClause = "where "; Iterator it = categories.iterator(); while (it.hasNext()) { ConceptType entry = null; if (whereClause.equals("where ")) { entry = (ConceptType) it.next(); whereClause = whereClause + " c_table_cd = '" + StringUtil.getTableCd(entry.getKey()) + "' "; } else { entry = (ConceptType) it.next(); whereClause = whereClause + " or " + " c_table_cd = '" + StringUtil.getTableCd(entry.getKey()) + "' "; } } String tableSql = "select distinct(c_table_name) from " + metadataSchema + "table_access " + whereClause; ParameterizedRowMapper<String> map = new ParameterizedRowMapper<String>() { public String mapRow(ResultSet rs, int rowNum) throws SQLException { String name = (rs.getString("c_table_name")); return name; } }; try { tableNames = jt.query(tableSql, map); } catch (DataAccessException e) { log.error(e.getMessage()); throw e; } } String hidden = ""; if (vocabType.isHiddens() == false) hidden = " and c_visualattributes not like '_H%'"; String synonym = ""; if (vocabType.isSynonyms() == false) synonym = " and c_synonym_cd = 'N'"; String codeInfoSql = null; if (tableNames != null) { Iterator it = tableNames.iterator(); String table = (String) it.next(); String tableCdSql = ", (select distinct(c_table_cd) from " + metadataSchema + "TABLE_ACCESS where c_table_name = '" + table + "') as tableCd"; String basecode = " '" + vocabType.getMatchStr().getValue() + "' "; codeInfoSql = "select " + parameters + tableCdSql + " from " + metadataSchema + table + " where upper(c_basecode) = " + basecode.toUpperCase() + hidden + synonym; ; while (it.hasNext()) { table = (String) it.next(); tableCdSql = ", (select distinct(c_table_cd) from " + metadataSchema + "TABLE_ACCESS where c_table_name = '" + table + "') as tableCd"; codeInfoSql = codeInfoSql + " union select " + parameters + tableCdSql + " from " + metadataSchema + table + " where upper(c_basecode) = " + basecode.toUpperCase() + hidden + synonym; } codeInfoSql = codeInfoSql + " order by c_name "; } else return null; log.debug(codeInfoSql); final boolean obfuscatedUserFlag = Roles.getInstance().isRoleOfuscated(projectInfo); ParameterizedRowMapper<ExpandedConceptType> mapper = new ParameterizedRowMapper<ExpandedConceptType>() { public ExpandedConceptType mapRow(ResultSet rs, int rowNum) throws SQLException { ExpandedConceptType entry = new ExpandedConceptType(); //TODO fix this for all/+blob entry.setName(rs.getString("c_name")); entry.setTableCd(rs.getString("tablecd")); if (vocabType.getType().equals("core")) { entry.setKey(rs.getString("c_fullname")); entry.setBasecode(rs.getString("c_basecode")); entry.setLevel(rs.getInt("c_hlevel")); entry.setSynonymCd(rs.getString("c_synonym_cd")); entry.setVisualattributes(rs.getString("c_visualattributes")); Integer totalNum = rs.getInt("c_totalnum"); if (obfuscatedUserFlag == false) { entry.setTotalnum(totalNum); } entry.setFacttablecolumn(rs.getString("c_facttablecolumn")); entry.setTablename(rs.getString("c_tablename")); entry.setColumnname(rs.getString("c_columnname")); entry.setColumndatatype(rs.getString("c_columndatatype")); entry.setOperator(rs.getString("c_operator")); entry.setDimcode(rs.getString("c_dimcode")); entry.setTooltip(rs.getString("c_tooltip")); } if ((vocabType.getType().equals("all"))) { DTOFactory factory = new DTOFactory(); // make sure date isnt null before converting to XMLGregorianCalendar Date date = rs.getDate("update_date"); if (date == null) entry.setUpdateDate(null); else entry.setUpdateDate(factory.getXMLGregorianCalendar(date.getTime())); date = rs.getDate("download_date"); if (date == null) entry.setDownloadDate(null); else entry.setDownloadDate(factory.getXMLGregorianCalendar(date.getTime())); date = rs.getDate("import_date"); if (date == null) entry.setImportDate(null); else entry.setImportDate(factory.getXMLGregorianCalendar(date.getTime())); entry.setSourcesystemCd(rs.getString("sourcesystem_cd")); entry.setValuetypeCd(rs.getString("valuetype_cd")); } return entry; } }; List queryResult = null; try { if (tableNames != null) queryResult = jt.query(codeInfoSql, mapper); } catch (DataAccessException e) { log.error(e.getMessage()); throw e; } log.debug("result size = " + queryResult.size()); if (queryResult != null) { if (parameters != DEFAULT) { // fix the key so it equals "\\tableCd\fullname" // in all cases but default Iterator it = queryResult.iterator(); while (it.hasNext()) { ExpandedConceptType entry = (ExpandedConceptType) it.next(); entry.setKey("\\\\" + entry.getTableCd() + entry.getKey()); } } // Cant gather clobs when you perform unions.... // So you have to loop through all the results and gather clobs if (vocabType.isBlob() == true) { Iterator itr = queryResult.iterator(); while (itr.hasNext()) { ConceptType child = (ConceptType) itr.next(); Iterator it = tableNames.iterator(); while (it.hasNext()) { String clobSql = "select c_metadataxml, c_comment from " + metadataSchema + (String) it.next() + " where c_name = ? and " + synonym; ParameterizedRowMapper<ConceptType> map = new ParameterizedRowMapper<ConceptType>() { public ConceptType mapRow(ResultSet rs, int rowNum) throws SQLException { ConceptType concept = new ConceptType(); try { if (rs.getClob("c_metadataxml") == null) { concept.setMetadataxml(null); } else { String c_xml = JDBCUtil.getClobString(rs.getClob("c_metadataxml")); if ((c_xml != null) && (c_xml.trim().length() > 0) && (!c_xml.equals("(null)"))) { SAXBuilder parser = new SAXBuilder(); java.io.StringReader xmlStringReader = new java.io.StringReader(c_xml); Element rootElement = null; try { org.jdom.Document metadataDoc = parser.build(xmlStringReader); org.jdom.output.DOMOutputter out = new DOMOutputter(); Document doc = out.output(metadataDoc); rootElement = doc.getDocumentElement(); } catch (JDOMException e) { log.error(e.getMessage()); concept.setMetadataxml(null); } if (rootElement != null) { XmlValueType xml = new XmlValueType(); xml.getAny().add(rootElement); concept.setMetadataxml(xml); } } else { concept.setMetadataxml(null); } } } catch (IOException e) { log.error(e.getMessage()); concept.setMetadataxml(null); } try { if (rs.getClob("c_comment") == null) { concept.setComment(null); } else { concept.setComment(JDBCUtil.getClobString(rs.getClob("c_comment"))); } } catch (IOException e) { log.error(e.getMessage()); concept.setComment(null); } return concept; } }; List clobResult = null; try { clobResult = jt.query(clobSql, map, child.getName(), child.getTooltip()); } catch (DataAccessException e) { log.error(e.getMessage()); throw e; } if (clobResult != null) { if ((((ConceptType) (clobResult.get(0))).getMetadataxml() != null) || (((ConceptType) (clobResult.get(0))).getComment() != null)) { child.setMetadataxml(((ConceptType) (clobResult.get(0))).getMetadataxml()); child.setComment(((ConceptType) (clobResult.get(0))).getComment()); break; } } else { child.setMetadataxml(null); child.setComment(null); } } } } } return queryResult; }
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; }/*from w w w .jav a 2s. c om*/ 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 ww w .j av a2 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.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 w w w. j a v a 2 s.co m 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()); }