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

📄 tdsresultsetmetadata.java

📁 Java写的TDS协议(JDBC/ODBC)实现
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    */
   public int getScale(int column) throws SQLException
   {
      int res = columnsInfo.getScale(column);
      return res<0 ? 0 : res;
   }

   /**
    * What's a column's table's schema?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return schema name or "" if not applicable
    * @exception SQLException if a database-access error occurs.
    */
   public String getSchemaName(int column) throws SQLException
   {
      String res = columnsInfo.getSchema(column);
      return res==null ? "" : res;
   }

   /**
    * What's a column's table name?
    *
    * @return table name or "" if not applicable
    * @exception SQLException if a database-access error occurs.
    */
   public String getTableName(int column) throws SQLException
   {
      String res = columnsInfo.getTableName(column);
      return res==null ? "" : res;
   }

   /**
    * Is the column automatically numbered, thus read-only?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return true if so
    * @exception SQLException if a database-access error occurs.
    */
   public boolean isAutoIncrement(int column) throws SQLException
   {
      return columnsInfo.isAutoIncrement(column).booleanValue();
   }

   /**
    * Does a column's case matter?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return true if so
    * @exception SQLException if a database-access error occurs.
    */
   public boolean isCaseSensitive(int column) throws SQLException
   {
      return columnsInfo.isCaseSensitive(column).booleanValue();
   }

   /**
    * Is the column a cash value?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return true if so
    * @exception SQLException if a database-access error occurs.
    */
   public boolean isCurrency(int column) throws SQLException
   {
      switch (columnsInfo.getNativeType(column))
      {
         case Tds.SYBMONEY:
         case Tds.SYBMONEYN:
         case Tds.SYBMONEY4:
         case Tds.SYBSMALLMONEY:
         {
            return true;
         }
         default:
         {
            return false;
         }
      }
   }

   /**
    * Will a write on the column definitely succeed?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return true if so
    * @exception SQLException if a database-access error occurs.
    */
   public boolean isDefinitelyWritable(int column) throws SQLException
   {
      return false;
   }

   /**
    * Can you put a NULL in this column?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return columnNoNulls, columnNullable or columnNullableUnknown
    * @exception SQLException if a database-access error occurs.
    */
   public int isNullable(int column) throws SQLException
   {
      return columnsInfo.isNullable(column);
   }

   /**
    * Is a column definitely not writable?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return true if so
    * @exception SQLException if a database-access error occurs.
    */
   public boolean isReadOnly(int column) throws SQLException
   {
      return columnsInfo.isReadOnly(column).booleanValue();
   }

   /**
    * Can the column be used in a where clause?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return true if so
    * @exception SQLException if a database-access error occurs.
    */
   public boolean isSearchable(int column) throws SQLException
   {
      return columnsInfo.getNativeType(column) != Tds.SYBIMAGE;
   }

   /**
    * Is the column a signed number?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return true if so
    * @exception SQLException if a database-access error occurs.
    */
   public boolean isSigned(int column) throws SQLException
   {
      switch( columnsInfo.getNativeType(column) )
      {
         case Tds.SYBDECIMAL:
         case Tds.SYBNUMERIC:
         case Tds.SYBMONEYN:
         case Tds.SYBMONEY:
         case Tds.SYBMONEY4:
         case Tds.SYBSMALLMONEY:
         case Tds.SYBFLTN:
         case Tds.SYBFLT8:
         case Tds.SYBREAL:
         case Tds.SYBINT2:
         case Tds.SYBINT4:
            return true;

         case Tds.SYBBIT:
         case Tds.SYBBITN:
         case Tds.SYBNVARCHAR:
         case Tds.SYBVARCHAR:
         case Tds.SYBNCHAR:
         case Tds.SYBCHAR:
         case Tds.SYBBINARY:
         case Tds.SYBVARBINARY:
         case Tds.SYBDATETIMN:
         case Tds.SYBDATETIME:
         case Tds.SYBDATETIME4:
         case Tds.SYBUNIQUEID:
         case Tds.SYBINT1:
         case Tds.SYBIMAGE:
         case Tds.SYBTEXT:
         case Tds.SYBNTEXT:
            return false;

         case Tds.SYBINTN:
            return columnsInfo.getBufferSize(column) > 1;

         default:
            throw new SQLException("Unknown column type.");
      }
   }

   /**
    * Is it possible for a write on the column to succeed?
    *
    * @param column the first column is 1, the second is 2, ...
    * @return true if so
    * @exception SQLException if a database-access error occurs.
    */
   public boolean isWritable(int column) throws SQLException
   {
      return !columnsInfo.isReadOnly(column).booleanValue();
   }

   /**
    * JDBC 2.0
    *
    * <p>Returns the fully-qualified name of the Java class whose instances
    * are manufactured if the method <code>ResultSet.getObject</code>
    * is called to retrieve a value
    * from the column.  <code>ResultSet.getObject</code> may return a subclass of the
    * class returned by this method.
    *
    * @return the fully-qualified name of the class in the Java programming
    *         language that would be used by the method
    * <code>ResultSet.getObject</code> to retrieve the value in the specified
    * column. This is the class name used for custom mapping.
    * @exception SQLException if a database access error occurs
    */
   public String getColumnClassName(int column) throws SQLException
   {
      switch( columnsInfo.getJdbcType(column) )
      {
         case Types.BIT:
            return "java.lang.Boolean";

         case Types.TINYINT:
         case Types.SMALLINT:
         case Types.INTEGER:
            return "java.lang.Integer";

         case Types.BIGINT:
         case Types.NUMERIC:
         case Types.DECIMAL:
            return "java.math.BigDecimal";

         case Types.FLOAT:
         case Types.DOUBLE:
            return "java.lang.Double";

         case Types.REAL:
            return "java.lang.Float";

         case Types.CHAR:
         case Types.VARCHAR:
         case Types.LONGVARCHAR:
            return "java.lang.String";

         case Types.DATE:
         case Types.TIME:
         case Types.TIMESTAMP:
            return "java.sql.Timestamp";

         case Types.BINARY:
         case Types.VARBINARY:
         case Types.LONGVARBINARY:
            return "byte[]";

         case Types.JAVA_OBJECT:
         case Types.DISTINCT:
         case Types.STRUCT:
         case Types.ARRAY:
         case Types.BLOB:
         case Types.CLOB:
         case Types.REF:
         default:
            // SAfe Or should this be null?
            return "";
      }
   }
}

⌨️ 快捷键说明

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