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

📄 resultsetmetadata.java

📁 mysql 5.1的 jdbc驱动 Connector/J 5.1 支持Mysql 4.1、Mysql 5.0、Mysql 5.1、Mysql 6.0 alpha这些版本。 Connector/J
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		switch (f.getMysqlType()) {		case MysqlDefs.FIELD_TYPE_TINY_BLOB:		case MysqlDefs.FIELD_TYPE_BLOB:		case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:		case MysqlDefs.FIELD_TYPE_LONG_BLOB:			return clampedGetLength(f); // this may change in the future		// for now, the server only		// returns FIELD_TYPE_BLOB for _all_		// BLOB types, but varying lengths		// indicating the _maximum_ size		// for each BLOB type.		default:			return clampedGetLength(f) / f.getMaxBytesPerCharacter();		}	}	/**	 * What is a column's number of digits to the right of the decimal point?	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return the scale	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public int getScale(int column) throws SQLException {		Field f = getField(column);		if (isDecimalType(f.getSQLType())) {			return f.getDecimals();		}		return 0;	}	/**	 * What is a column's table's schema? This relies on us knowing the table	 * name. The JDBC specification allows us to return "" if this is not	 * applicable.	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return the Schema	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public String getSchemaName(int column) throws SQLException {		return ""; //$NON-NLS-1$	}	/**	 * Whats a column's table's name?	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return column name, or "" if not applicable	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public String getTableName(int column) throws SQLException {		if (this.useOldAliasBehavior) {			return getField(column).getTableName();		}				return getField(column).getTableNameNoAliases();	}	/**	 * Is the column automatically numbered (and thus read-only)	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return true if so	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public boolean isAutoIncrement(int column) throws SQLException {		Field f = getField(column);		return f.isAutoIncrement();	}	/**	 * Does a column's case matter?	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return true if so	 * 	 * @throws java.sql.SQLException	 *             if a database access error occurs	 */	public boolean isCaseSensitive(int column) throws java.sql.SQLException {		Field field = getField(column);		int sqlType = field.getSQLType();		switch (sqlType) {		case Types.BIT:		case Types.TINYINT:		case Types.SMALLINT:		case Types.INTEGER:		case Types.BIGINT:		case Types.FLOAT:		case Types.REAL:		case Types.DOUBLE:		case Types.DATE:		case Types.TIME:		case Types.TIMESTAMP:			return false;		case Types.CHAR:		case Types.VARCHAR:		case Types.LONGVARCHAR:			if (field.isBinary()) {				return true;			}			String collationName = field.getCollation();			return ((collationName != null) && !collationName.endsWith("_ci"));		default:			return true;		}	}	/**	 * Is the column a cash value?	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return true if its a cash column	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public boolean isCurrency(int column) throws SQLException {		return false;	}	/**	 * Will a write on this column definately succeed?	 * 	 * @param column	 *            the first column is 1, the second is 2, etc..	 * 	 * @return true if so	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public boolean isDefinitelyWritable(int column) throws SQLException {		return isWritable(column);	}	/**	 * Can you put a NULL in this column?	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return one of the columnNullable values	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public int isNullable(int column) throws SQLException {		if (!getField(column).isNotNull()) {			return java.sql.ResultSetMetaData.columnNullable;		}		return java.sql.ResultSetMetaData.columnNoNulls;	}	/**	 * Is the column definitely not writable?	 * 	 * @param column	 *            the first column is 1, the second is 2, etc.	 * 	 * @return true if so	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public boolean isReadOnly(int column) throws SQLException {		return getField(column).isReadOnly();	}	/**	 * Can the column be used in a WHERE clause? Basically for this, I split the	 * functions into two types: recognised types (which are always useable),	 * and OTHER types (which may or may not be useable). The OTHER types, for	 * now, I will assume they are useable. We should really query the catalog	 * to see if they are useable.	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return true if they can be used in a WHERE clause	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public boolean isSearchable(int column) throws SQLException {		return true;	}	/**	 * Is the column a signed number?	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return true if so	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public boolean isSigned(int column) throws SQLException {		Field f = getField(column);		int sqlType = f.getSQLType();		switch (sqlType) {		case Types.TINYINT:		case Types.SMALLINT:		case Types.INTEGER:		case Types.BIGINT:		case Types.FLOAT:		case Types.REAL:		case Types.DOUBLE:		case Types.NUMERIC:		case Types.DECIMAL:			return !f.isUnsigned();		case Types.DATE:		case Types.TIME:		case Types.TIMESTAMP:			return false;		default:			return false;		}	}	/**	 * Is it possible for a write on the column to succeed?	 * 	 * @param column	 *            the first column is 1, the second is 2, etc.	 * 	 * @return true if so	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public boolean isWritable(int column) throws SQLException {		return !isReadOnly(column);	}	/**	 * Returns a string representation of this object	 * 	 * @return ...	 */	public String toString() {		StringBuffer toStringBuf = new StringBuffer();		toStringBuf.append(super.toString());		toStringBuf.append(" - Field level information: "); //$NON-NLS-1$		for (int i = 0; i < this.fields.length; i++) {			toStringBuf.append("\n\t"); //$NON-NLS-1$			toStringBuf.append(this.fields[i].toString());		}		return toStringBuf.toString();	}		static String getClassNameForJavaType(int javaType, 			boolean isUnsigned, int mysqlTypeIfKnown, 			boolean isBinaryOrBlob,			boolean isOpaqueBinary) {		switch (javaType) {		case Types.BIT:		case Types.BOOLEAN:			return "java.lang.Boolean"; //$NON-NLS-1$		case Types.TINYINT:			if (isUnsigned) {				return "java.lang.Integer"; //$NON-NLS-1$			}			return "java.lang.Integer"; //$NON-NLS-1$		case Types.SMALLINT:			if (isUnsigned) {				return "java.lang.Integer"; //$NON-NLS-1$			}			return "java.lang.Integer"; //$NON-NLS-1$		case Types.INTEGER:			if (!isUnsigned || 					mysqlTypeIfKnown == MysqlDefs.FIELD_TYPE_INT24) {				return "java.lang.Integer"; //$NON-NLS-1$			}			return "java.lang.Long"; //$NON-NLS-1$		case Types.BIGINT:			if (!isUnsigned) {				return "java.lang.Long"; //$NON-NLS-1$			}			return "java.math.BigInteger"; //$NON-NLS-1$		case Types.DECIMAL:		case Types.NUMERIC:			return "java.math.BigDecimal"; //$NON-NLS-1$		case Types.REAL:			return "java.lang.Float"; //$NON-NLS-1$		case Types.FLOAT:		case Types.DOUBLE:			return "java.lang.Double"; //$NON-NLS-1$		case Types.CHAR:		case Types.VARCHAR:		case Types.LONGVARCHAR:			if (!isOpaqueBinary) {				return "java.lang.String"; //$NON-NLS-1$			}			return "[B";		case Types.BINARY:		case Types.VARBINARY:		case Types.LONGVARBINARY:			if (mysqlTypeIfKnown == MysqlDefs.FIELD_TYPE_GEOMETRY) {				return "[B";			} else if (isBinaryOrBlob) {				return "[B";			} else {				return "java.lang.String";			}		case Types.DATE:			return "java.sql.Date"; //$NON-NLS-1$		case Types.TIME:			return "java.sql.Time"; //$NON-NLS-1$		case Types.TIMESTAMP:			return "java.sql.Timestamp"; //$NON-NLS-1$		default:			return "java.lang.Object"; //$NON-NLS-1$		}	}		/**     * Returns true if this either implements the interface argument or is directly or indirectly a wrapper     * for an object that does. Returns false otherwise. If this implements the interface then return true,     * else if this is a wrapper then return the result of recursively calling <code>isWrapperFor</code> on the wrapped     * object. If this does not implement the interface and is not a wrapper, return false.     * This method should be implemented as a low-cost operation compared to <code>unwrap</code> so that     * callers can use this method to avoid expensive <code>unwrap</code> calls that may fail. If this method     * returns true then calling <code>unwrap</code> with the same argument should succeed.     *     * @param interfaces a Class defining an interface.     * @return true if this implements the interface or directly or indirectly wraps an object that does.     * @throws java.sql.SQLException  if an error occurs while determining whether this is a wrapper     * for an object with the given interface.     * @since 1.6     */	public boolean isWrapperFor(Class iface) throws SQLException {		// This works for classes that aren't actually wrapping		// anything		return iface.isInstance(this);	}    /**     * Returns an object that implements the given interface to allow access to non-standard methods,     * or standard methods not exposed by the proxy.     * The result may be either the object found to implement the interface or a proxy for that object.     * If the receiver implements the interface then that is the object. If the receiver is a wrapper     * and the wrapped object implements the interface then that is the object. Otherwise the object is     *  the result of calling <code>unwrap</code> recursively on the wrapped object. If the receiver is not a     * wrapper and does not implement the interface, then an <code>SQLException</code> is thrown.     *     * @param iface A Class defining an interface that the result must implement.     * @return an object that implements the interface. May be a proxy for the actual implementing object.     * @throws java.sql.SQLException If no object found that implements the interface      * @since 1.6     */	public Object unwrap(Class iface) throws java.sql.SQLException {    	try {    		// This works for classes that aren't actually wrapping    		// anything    		return Util.cast(iface, this);        } catch (ClassCastException cce) {            throw SQLError.createSQLException("Unable to unwrap to " + iface.toString(),             		SQLError.SQL_STATE_ILLEGAL_ARGUMENT);        }    }}

⌨️ 快捷键说明

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