getVersionColumns Method (SQLServerDatabaseMetaData)
Retrieves a description of the columns of a table that is automatically updated when any value in a row is updated.
Syntax
public java.sql.ResultSet getVersionColumns(java.lang.String catalog,
java.lang.String schema,
java.lang.String table)
Parameters
catalog
A String that contains the catalog name.
schema
A String that contains the schema name pattern.
table
A String that contains the table name.
Return Value
A SQLServerResultSet object.
Exceptions
Remarks
This getVersionColumns method is specified by the getVersionColumns method in the java.sql.DatabaseMetaData interface.
The result set returned by the getVersionColumns method will contain the following information:
Name |
Type |
Description |
---|---|---|
SCOPE |
short |
Not supported by the JDBC driver. |
COLUMN_NAME |
String |
The column name. |
DATA_TYPE |
short |
The SQL data type from java.sql.Types. |
TYPE_NAME |
String |
The name of the data type. |
COLUMN_SIZE |
int |
The precision of the column. |
BUFFER_LENGTH |
int |
The length of the column in bytes. |
DECIMAL_DIGITS |
short |
The scale of the column. |
PSEUDO_COLUMN |
short |
Indicates if the column is a pseudo column. It can be one of the following values: versionColumnUnknown (0) versionColumnNotPseudo (1) versionColumnPseudo (2) |
Note
For more information about the data returned by the getVersionColumns method, see "sp_datatype_info (Transact-SQL)" in SQL Server Books Online.
Example
The following example demonstrates how to use the getVersionColumns method to return information about the columns that are automatically updated in the Person.Contact table in the SQL Server 2005 AdventureWorks sample database.
public static void executeGetVersionColumns(Connection con) {
try {
DatabaseMetaData dbmd = con.getMetaData();
ResultSet rs = dbmd.getVersionColumns("AdventureWorks", "Person", "Contact");
ResultSetMetaData rsmd = rs.getMetaData();
// Display the result set data.
int cols = rsmd.getColumnCount();
while(rs.next()) {
for (int i = 1; i <= cols; i++) {
System.out.println(rs.getString(i));
}
}
rs.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
See Also
Reference
SQLServerDatabaseMetaData Class