📄 databasemetadata.java
字号:
*/
public int getMaxColumnsInSelect() throws SQLException
{
// XXX Need to check for Sybase
return 4000;
// per "Programming ODBC for SQLServer" Appendix A
}
/**
* What's the maximum number of columns in a table?
*
*@return max columns
*@exception SQLException if a database-access error occurs.
*/
public int getMaxColumnsInTable() throws SQLException
{
// XXX How do we find this out for Sybase?
return 250;
// per "Programming ODBC for SQLServer" Appendix A
}
/**
* How many active connections can we have at a time to this database?
*
*@return max connections
*@exception SQLException if a database-access error occurs.
*/
public int getMaxConnections() throws SQLException
{
// XXX need to find out if this is still true for SYBASE
// per SQL Server Books Online "Administrator's Companion",
// Part 1, Chapter 1.
return 32767;
}
/**
* What's the maximum cursor name length?
*
*@return max cursor name length in bytes
*@exception SQLException if a database-access error occurs.
*/
public int getMaxCursorNameLength() throws SQLException
{
// XXX Need to check for Sybase
return sysnameLength; // per "Programming ODBC for SQLServer" Appendix A
// per "Programming ODBC for SQLServer" Appendix A
}
/**
* What's the maximum length of an index (in bytes)?
*
*@return max index length in bytes
*@exception SQLException if a database-access error occurs.
*/
public int getMaxIndexLength() throws SQLException
{
// XXX Need to check for Sybase
return 900;
// per "Programming ODBC for SQLServer" Appendix A
}
/**
* What's the maximum length of a procedure name?
*
*@return max name length in bytes
*@exception SQLException if a database-access error occurs.
*/
public int getMaxProcedureNameLength() throws SQLException
{
// XXX Need to check for Sybase
return sysnameLength; // per "Programming ODBC for SQLServer" Appendix A
// per "Programming ODBC for SQLServer" Appendix A
}
/**
* What's the maximum length of a single row?
*
*@return max row size in bytes
*@exception SQLException if a database-access error occurs.
*/
public int getMaxRowSize() throws SQLException
{
// XXX need to find out if this is still true for SYBASE
// per SQL Server Books Online "Administrator's Companion",
// Part 1, Chapter 1.
return 1962;
}
/**
* What's the maximum length allowed for a schema name?
*
*@return max name length in bytes
*@exception SQLException if a database-access error occurs.
*/
public int getMaxSchemaNameLength() throws SQLException
{
return sysnameLength;
}
/**
* What's the maximum length of a SQL statement?
*
*@return max length in bytes
*@exception SQLException if a database-access error occurs.
*/
public int getMaxStatementLength() throws SQLException
{
// XXX Need to check for Sybase
return 131072;
// per "Programming ODBC for SQLServer" Appendix A
}
/**
* How many active statements can we have open at one time to this
* database?
*
*@return the maximum
*@exception SQLException if a database-access error occurs.
*/
public int getMaxStatements() throws SQLException
{
return 0;
}
/**
* What's the maximum length of a table name?
*
*@return max name length in bytes
*@exception SQLException if a database-access error occurs.
*/
public int getMaxTableNameLength() throws SQLException
{
// XXX Need to check for Sybase
return sysnameLength; // per "Programming ODBC for SQLServer" Appendix A
// per "Programming ODBC for SQLServer" Appendix A
}
/**
* What's the maximum number of tables in a SELECT?
*
*@return the maximum
*@exception SQLException if a database-access error occurs.
*/
public int getMaxTablesInSelect() throws SQLException
{
// XXX Need to check for Sybase
return 16;
// per "Programming ODBC for SQLServer" Appendix A
}
/**
* What's the maximum length of a user name?
*
*@return max name length in bytes
*@exception SQLException if a database-access error occurs.
*/
public int getMaxUserNameLength() throws SQLException
{
// XXX need to find out if this is still true for SYBASE
return sysnameLength;
}
/**
* Get a comma separated list of math functions.
*
*@return the list
*@exception SQLException if a database-access error occurs.
*/
public String getNumericFunctions() throws SQLException
{
// @todo Implement (a)%(b) for MOD(a,b)
// XXX need to find out if this is still true for SYBASE
return "ABS,ACOS,ASIN,ATAN,ATAN2,CEILING,COS,COT,DEGREES,EXP,FLOOR,LOG,LOG10,PI,POWER,RADIANS,RAND,ROUND,SIGN,SIN,SQRT,TAN";
}
/**
* Get a description of a table's primary key columns. They are ordered by
* COLUMN_NAME. <P>
*
* Each primary key column description has the following columns:
* <OL>
* <LI> <B>TABLE_CAT</B> String =>table catalog (may be null)
* <LI> <B>TABLE_SCHEM</B> String =>table schema (may be null)
* <LI> <B>TABLE_NAME</B> String =>table name
* <LI> <B>COLUMN_NAME</B> String =>column name
* <LI> <B>KEY_SEQ</B> short =>sequence number within primary key
* <LI> <B>PK_NAME</B> String =>primary key name (may be null)
* </OL>
*
*
*@param catalog a catalog name; "" retrieves those without a
* catalog; null means drop catalog name from the selection criteria
*@param schema a schema name pattern; "" retrieves those
* without a schema
*@param table a table name
*@return ResultSet - each row is a primary key column
* description
*@exception SQLException if a database-access error occurs.
*/
public java.sql.ResultSet getPrimaryKeys(
String catalog,
String schema,
String table)
throws SQLException
{
String query = "exec sp_pkeys ?, ?, ?";
if( catalog != null )
query = "exec "+catalog+"..sp_pkeys ?, ?, ?";
CallableStatement s = connection.prepareCall(query);
s.setString(1, table);
s.setString(2, schema);
s.setString(3, catalog);
TdsResultSet rs = (TdsResultSet)s.executeQuery();
Columns col = rs.getContext().getColumnInfo();
col.setName(1, "TABLE_CAT");
col.setLabel(1, "TABLE_CAT");
col.setName(2, "TABLE_SCHEM");
col.setLabel(2, "TABLE_SCHEM");
return rs;
}
/**
* Get a description of a catalog's stored procedure parameters and result
* columns. <P>
*
* Only descriptions matching the schema, procedure and parameter name
* criteria are returned. They are ordered by PROCEDURE_SCHEM and
* PROCEDURE_NAME. Within this, the return value, if any, is first. Next
* are the parameter descriptions in call order. The column descriptions
* follow in column number order. <P>
*
* Each row in the ResultSet is a parameter description or column
* description with the following fields:
* <OL>
* <LI> <B>PROCEDURE_CAT</B> String =>procedure catalog (may be null)
*
* <LI> <B>PROCEDURE_SCHEM</B> String =>procedure schema (may be null)
*
* <LI> <B>PROCEDURE_NAME</B> String =>procedure name
* <LI> <B>COLUMN_NAME</B> String =>column/parameter name
* <LI> <B>COLUMN_TYPE</B> Short =>kind of column/parameter:
* <UL>
* <LI> procedureColumnUnknown - nobody knows
* <LI> procedureColumnIn - IN parameter
* <LI> procedureColumnInOut - INOUT parameter
* <LI> procedureColumnOut - OUT parameter
* <LI> procedureColumnReturn - procedure return value
* <LI> procedureColumnResult - result column in ResultSet
* </UL>
*
* <LI> <B>DATA_TYPE</B> short =>SQL type from java.sql.Types
* <LI> <B>TYPE_NAME</B> String =>SQL type name
* <LI> <B>PRECISION</B> int =>precision
* <LI> <B>LENGTH</B> int =>length in bytes of data
* <LI> <B>SCALE</B> short =>scale
* <LI> <B>RADIX</B> short =>radix
* <LI> <B>NULLABLE</B> short =>can it contain NULL?
* <UL>
* <LI> procedureNoNulls - does not allow NULL values
* <LI> procedureNullable - allows NULL values
* <LI> procedureNullableUnknown - nullability unknown
* </UL>
*
* <LI> <B>REMARKS</B> String =>comment describing parameter/column
* </OL>
* <P>
*
* <B>Note:</B> Some databases may not return the column descriptions for a
* procedure. Additional columns beyond REMARKS can be defined by the
* database.
*
*@param catalog a catalog name; "" retrieves those without a
* catalog; null means drop catalog name from the selection criteria
*@param schemaPattern a schema name pattern; "" retrieves those
* without a schema
*@param procedureNamePattern a procedure name pattern
*@param columnNamePattern a column name pattern
*@return ResultSet - each row is a stored procedure
* parameter or column description
*@exception SQLException if a database-access error occurs.
*@see #getSearchStringEscape
*/
public java.sql.ResultSet getProcedureColumns(
String catalog,
String schemaPattern,
String procedureNamePattern,
String columnNamePattern )
throws SQLException
{
String query = "exec sp_sproc_columns ?, ?, ?, ?, 3";
if( catalog != null )
query = "exec "+catalog+"..sp_sproc_columns ?, ?, ?, ?, 3";
CallableStatement s = connection.prepareCall(query);
s.setString(1, procedureNamePattern);
s.setString(2, schemaPattern);
s.setString(3, catalog);
s.setString(4, columnNamePattern);
TdsResultSet rs = (TdsResultSet)s.executeQuery();
Columns col = rs.getContext().getColumnInfo();
col.setName(1, "PROCEDURE_CAT");
col.setLabel(1, "PROCEDURE_CAT");
col.setName(2, "PROCEDURE_SCHEM");
col.setLabel(2, "PROCEDURE_SCHEM");
return rs;
}
/**
* Get a description of stored procedures available in a catalog. <P>
*
* Only procedure descriptions matching the schema and procedure name
* criteria are returned. They are ordered by PROCEDURE_SCHEM, and
* PROCEDURE_NAME. <P>
*
* Each procedure description has the the following columns:
* <OL>
* <LI> <B>PROCEDURE_CAT</B> String =>procedure catalog (may be null)
*
* <LI> <B>PROCEDURE_SCHEM</B> String =>procedure schema (may be null)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -