⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 databasemetadata.java

📁 数据仓库工具
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    * @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
   {
      NotImplemented(); return 0;
   }


   /**
    * 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
//sinisa
		return 0x20000;
   }


   /**
    * 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
   {
      /*
      NotImplemented(); 
      return 0;
      */
//      return 128;
//sinisa
      return 32767;
   }


   /**
    * 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 30; // 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 30;
   }


   /**
    * Get a comma separated list of math functions.
    *
    * @return the list
    * @exception SQLException if a database-access error occurs.
    */
   public String getNumericFunctions() throws SQLException
   {
      // XXX need to find out if this is still true for SYBASE
      return "ABS,ACOS,ASIN,ATAN,ATN2,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
   {
      NotImplemented(); return null;
   }


   /**
    * 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
   {
      NotImplemented(); return null;
   }


   /**
    * 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)
    *   <LI><B>PROCEDURE_NAME</B> String => procedure name
    *  <LI> reserved for future use
    *  <LI> reserved for future use
    *  <LI> reserved for future use
    *   <LI><B>REMARKS</B> String => explanatory comment on the procedure
    *   <LI><B>PROCEDURE_TYPE</B> short => kind of procedure:
    *      <UL>
    *      <LI> procedureResultUnknown - May return a result
    *      <LI> procedureNoResult - Does not return a result
    *      <LI> procedureReturnsResult - Returns a result
    *      </UL>
    *  </OL>
    *
    * @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
    * @return ResultSet - each row is a procedure description
    * @exception SQLException if a database-access error occurs.
    * @see #getSearchStringEscape
    */
   public java.sql.ResultSet getProcedures(String catalog,
                                           String schemaPattern,
                                           String procedureNamePattern) 
      throws SQLException
   {
      debugPrintln("Inside of getProcedures");
      debugPrintln("  catalog is |" + catalog + "|");
      debugPrintln("  schemaPattern is " + schemaPattern);
      debugPrintln("  procedurePattern is " + procedureNamePattern);
      
      schemaPattern = schemaPattern.trim();

      if (tds.getDatabaseProductName().indexOf("Microsoft") >= 0
          && tds.getDatabaseProductVersion().startsWith("7."))
      {
         String query;
         
         query = ("select PROCEDURE_CAT=?, "
                  + " PROCEDURE_SCHEM=substring(u.name, 1, 32), "
                  + " PROCEDURE_NAME=substring(o.name, 1, 32), "
                  + " '', '', '', "
                  + " REMARKS='', PROCEDURE_TYPE=" 
                  + java.sql.DatabaseMetaData.procedureResultUnknown
                  + " from ");
         if (catalog != null && (!catalog.equals("")))
         {
            // XXX need to make sure user doesn't pass in funky strings
            query = query + catalog + ".";
         }
         query = query + "dbo.sysobjects o,  ";
         
         if (catalog != null && (!catalog.equals("")))
         {
            // XXX need to make sure user doesn't pass in funky strings
            query = query + catalog + ".";
         }
         query = query + "dbo.sysusers u ";

         query = query + " where o.uid=u.uid and xtype='P' ";
         query = query + " and u.name like ? "; // schema name
         query = query + " and o.name like ? ";   // procedure name

         debugPrintln("Query is |" + query + "|");

         java.sql.PreparedStatement ps = connection.prepareStatement(query);

         debugPrintln("ps.setString(1, \"" + catalog + "\")");
         ps.setString(1, catalog);
         if (schemaPattern==null || schemaPattern.equals(""))
         {
            debugPrintln("ps.setString(2, \"%\");");
            ps.setString(2, "%");
         }
         else
         {
            debugPrintln("ps.setString(2, \"" + schemaPattern + "\")");
            ps.setString(2, schemaPattern);
         }
         if (procedureNamePattern==null || procedureNamePattern.equals(""))
         {
            debugPrintln("ps.setString(3, \"%\");");
            ps.setString(3, "%");
         }
         else
         {
            debugPrintln("ps.setString(3, \"" + procedureNamePattern + "\")");
            ps.setString(3, procedureNamePattern);
         }
         
         java.sql.ResultSet rs = ps.executeQuery();

         return rs;
      }
      else
      {
         NotImplemented(); return null;
      }
   }


   /**
    * What's the database vendor's preferred term for "procedure"?
    *
    * @return the vendor term
    * @exception SQLException if a database-access error occurs.
    */
   public String getProcedureTerm() throws SQLException
   {
      // XXX Need to check for Sybase

      // per "Programming ODBC for SQLServer" Appendix A
      return "stored procedure";
   }


   /**
    * Get the schema names available in this database.  The results
    * are ordered by schema name.
    *
    * <P>The schema column is:
    *  <OL>
    *   <LI><B>TABLE_SCHEM</B> String => schema name
    *  </OL>
    *
    * @return ResultSet - each row has a single String column that is a
    * schema name
    * @exception SQLException if a database-access error occurs.
    */
   public java.sql.ResultSet getSchemas() throws SQLException
   {
      // XXX We should really clean up all these temporary tables.
      String tmpName = "#t#" + Un

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -