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

📄 resultsetmetadata.java

📁 mysql的jdbc驱动
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			return field.isUnsigned() ? "DOUBLE UNSIGNED" : "DOUBLE";		case MysqlDefs.FIELD_TYPE_NULL:			return "NULL"; //$NON-NLS-1$		case MysqlDefs.FIELD_TYPE_TIMESTAMP:			return "TIMESTAMP"; //$NON-NLS-1$       		case MysqlDefs.FIELD_TYPE_LONGLONG:			return field.isUnsigned() ? "BIGINT UNSIGNED" : "BIGINT";		case MysqlDefs.FIELD_TYPE_INT24:			return field.isUnsigned() ? "MEDIUMINT UNSIGNED" : "MEDIUMINT";		case MysqlDefs.FIELD_TYPE_DATE:			return "DATE"; //$NON-NLS-1$       		case MysqlDefs.FIELD_TYPE_TIME:			return "TIME"; //$NON-NLS-1$       		case MysqlDefs.FIELD_TYPE_DATETIME:			return "DATETIME"; //$NON-NLS-1$      		case MysqlDefs.FIELD_TYPE_TINY_BLOB:			return "TINYBLOB"; //$NON-NLS-1$		case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB:			return "MEDIUMBLOB"; //$NON-NLS-1$		case MysqlDefs.FIELD_TYPE_LONG_BLOB:			return "LONGBLOB"; //$NON-NLS-1$		case MysqlDefs.FIELD_TYPE_BLOB:			if (getField(column).isBinary()) {				return "BLOB";//$NON-NLS-1$			}			return "TEXT";//$NON-NLS-1$		case MysqlDefs.FIELD_TYPE_VARCHAR:			return "VARCHAR"; //$NON-NLS-1$		case MysqlDefs.FIELD_TYPE_VAR_STRING:			return "VARCHAR"; //$NON-NLS-1$		case MysqlDefs.FIELD_TYPE_STRING:			return "CHAR"; //$NON-NLS-1$		case MysqlDefs.FIELD_TYPE_ENUM:			return "ENUM"; //$NON-NLS-1$		case MysqlDefs.FIELD_TYPE_YEAR:			return "YEAR"; // $NON_NLS-1$		case MysqlDefs.FIELD_TYPE_SET:			return "SET"; //$NON-NLS-1$		default:			return "UNKNOWN"; //$NON-NLS-1$		}	}	/**	 * Returns the field instance for the given column index	 * 	 * @param columnIndex	 *            the column number to retrieve a field instance for	 * 	 * @return the field instance for the given column index	 * 	 * @throws SQLException	 *             if an error occurs	 */	protected Field getField(int columnIndex) throws SQLException {		if ((columnIndex < 1) || (columnIndex > this.fields.length)) {			throw new SQLException(Messages.getString("ResultSetMetaData.46"), //$NON-NLS-1$					SQLError.SQL_STATE_INVALID_COLUMN_NUMBER);		}		return this.fields[columnIndex - 1];	}	/**	 * What is a column's number of decimal digits.	 * 	 * @param column	 *            the first column is 1, the second is 2...	 * 	 * @return the precision	 * 	 * @throws SQLException	 *             if a database access error occurs	 */	public int getPrecision(int column) throws SQLException {		Field f = getField(column);		// if (f.getMysqlType() == MysqlDefs.FIELD_TYPE_NEW_DECIMAL) {		// return f.getLength();		// }		if (isDecimalType(f.getSQLType())) {			if (f.getDecimals() > 0) {				return clampedGetLength(f) - 1 + f.getPrecisionAdjustFactor();			}			return clampedGetLength(f) + f.getPrecisionAdjustFactor();		}		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 {		return getField(column).getTableName();	}	/**	 * 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;		}	}	// *********************************************************************	//	// END OF PUBLIC INTERFACE	//	// *********************************************************************	/**	 * 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();	}}

⌨️ 快捷键说明

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