List of usage examples for java.sql DatabaseMetaData versionColumnPseudo
int versionColumnPseudo
To view the source code for java.sql DatabaseMetaData versionColumnPseudo.
Click Source Link
From source file:org.apache.ddlutils.task.DumpMetadataTask.java
/** * Dumps the versioned (auto-updating) columns of the indicated table. * /*from w w w. jav a 2 s .c om*/ * @param xmlWriter The xml writer to write to * @param metaData The database metadata * @param catalogName The catalog name * @param schemaName The schema name * @param tableName The table name */ private void dumpVersionColumns(PrettyPrintingXmlWriter xmlWriter, final DatabaseMetaData metaData, final String catalogName, final String schemaName, final String tableName) throws SQLException { performResultSetXmlOperation(xmlWriter, null, new ResultSetXmlOperation() { public ResultSet getResultSet() throws SQLException { return metaData.getVersionColumns(catalogName, schemaName, tableName); } public void handleRow(PrettyPrintingXmlWriter xmlWriter, ResultSet result) throws SQLException { Set columns = getColumnsInResultSet(result); String columnName = result.getString("COLUMN_NAME"); if ((columnName != null) && (columnName.length() > 0)) { xmlWriter.writeElementStart(null, "versionedColumn"); xmlWriter.writeAttribute(null, "column", columnName); addIntAttribute(xmlWriter, "typeCode", result, columns, "DATA_TYPE"); addStringAttribute(xmlWriter, "type", result, columns, "TYPE_NAME"); addIntAttribute(xmlWriter, "size", result, columns, "BUFFER_LENGTH"); addIntAttribute(xmlWriter, "precision", result, columns, "COLUMN_SIZE"); addShortAttribute(xmlWriter, "scale", result, columns, "DECIMAL_DIGITS"); if (columns.contains("PSEUDO_COLUMN")) { try { switch (result.getShort("PSEUDO_COLUMN")) { case DatabaseMetaData.versionColumnPseudo: xmlWriter.writeAttribute(null, "columnType", "pseudo column"); break; case DatabaseMetaData.versionColumnNotPseudo: xmlWriter.writeAttribute(null, "columnType", "real column"); break; default: xmlWriter.writeAttribute(null, "columnType", "unknown"); break; } } catch (SQLException ex) { log("Could not read the PSEUDO_COLUMN value for versioned colum '" + columnName + "' of table '" + tableName + "' from the result set: " + ex.getStackTrace(), Project.MSG_ERR); } } xmlWriter.writeElementEnd(); } } public void handleError(SQLException ex) { log("Could not read the versioned columns for table '" + tableName + "' from the result set: " + ex.getStackTrace(), Project.MSG_ERR); } }); }