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

📄 resultset.java

📁 mysql的jdbc驱动
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	 * @param colName	 *            the column name	 * 	 * @return an object representing an SQL array	 * 	 * @throws SQLException	 *             if a database error occurs	 * @throws NotImplemented	 *             DOCUMENT ME!	 */	public java.sql.Array getArray(String colName) throws SQLException {		throw new NotImplemented();	}	/**	 * A column value can be retrieved as a stream of ASCII characters and then	 * read in chunks from the stream. This method is particulary suitable for	 * retrieving large LONGVARCHAR values. The JDBC driver will do any	 * necessary conversion from the database format into ASCII.	 * 	 * <p>	 * <B>Note:</B> All the data in the returned stream must be read prior to	 * getting the value of any other column. The next call to a get method	 * implicitly closes the stream. Also, a stream may return 0 for available()	 * whether there is data available or not.	 * </p>	 * 	 * @param columnIndex	 *            the first column is 1, the second is 2, ...	 * 	 * @return a Java InputStream that delivers the database column value as a	 *         stream of one byte ASCII characters. If the value is SQL NULL	 *         then the result is null	 * 	 * @exception SQLException	 *                if a database access error occurs	 * 	 * @see getBinaryStream	 */	public InputStream getAsciiStream(int columnIndex) throws SQLException {		checkRowPos();		if (!this.isBinaryEncoded) {			return getBinaryStream(columnIndex);		}		return getNativeBinaryStream(columnIndex);	}	/**	 * DOCUMENT ME!	 * 	 * @param columnName	 *            DOCUMENT ME!	 * 	 * @return DOCUMENT ME!	 * 	 * @throws SQLException	 *             DOCUMENT ME!	 */	public InputStream getAsciiStream(String columnName) throws SQLException {		return getAsciiStream(findColumn(columnName));	}	/**	 * JDBC 2.0 Get the value of a column in the current row as a	 * java.math.BigDecimal object.	 * 	 * @param columnIndex	 *            the first column is 1, the second is 2, ...	 * 	 * @return the column value (full precision); if the value is SQL NULL, the	 *         result is null	 * 	 * @exception SQLException	 *                if a database-access error occurs.	 */	public BigDecimal getBigDecimal(int columnIndex) throws SQLException {		if (!this.isBinaryEncoded) {			String stringVal = getString(columnIndex);			BigDecimal val;			if (stringVal != null) {				if (stringVal.length() == 0) {					val = new BigDecimal(convertToZeroWithEmptyCheck());					return val;				}				try {					val = new BigDecimal(stringVal);					return val;				} catch (NumberFormatException ex) {					throw new SQLException(Messages							.getString("ResultSet.Bad_format_for_BigDecimal",									new Object[] { stringVal,											new Integer(columnIndex) }),							SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$				}			}			return null;		}		return getNativeBigDecimal(columnIndex);	}	/**	 * Get the value of a column in the current row as a java.math.BigDecimal	 * object	 * 	 * @param columnIndex	 *            the first column is 1, the second is 2...	 * @param scale	 *            the number of digits to the right of the decimal	 * 	 * @return the column value; if the value is SQL NULL, null	 * 	 * @exception SQLException	 *                if a database access error occurs	 * 	 * @deprecated	 */	public BigDecimal getBigDecimal(int columnIndex, int scale)			throws SQLException {		if (!this.isBinaryEncoded) {			String stringVal = getString(columnIndex);			BigDecimal val;			if (stringVal != null) {				if (stringVal.length() == 0) {					val = new BigDecimal(convertToZeroWithEmptyCheck());					try {						return val.setScale(scale);					} catch (ArithmeticException ex) {						try {							return val									.setScale(scale, BigDecimal.ROUND_HALF_UP);						} catch (ArithmeticException arEx) {							throw new SQLException(									Messages											.getString("ResultSet.Bad_format_for_BigDecimal____124") //$NON-NLS-1$											+ stringVal											+ Messages													.getString("ResultSet.___in_column__125")											+ columnIndex											+ "(" //$NON-NLS-1$											+ this.fields[columnIndex - 1]											+ ").",									SQLError.SQL_STATE_ILLEGAL_ARGUMENT);						}					}				}				try {					val = new BigDecimal(stringVal);				} catch (NumberFormatException ex) {					throw new SQLException(Messages							.getString("ResultSet.Bad_format_for_BigDecimal",									new Object[] { new Integer(columnIndex),											stringVal }),							SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$				}				try {					return val.setScale(scale);				} catch (ArithmeticException ex) {					try {						return val.setScale(scale, BigDecimal.ROUND_HALF_UP);					} catch (ArithmeticException arithEx) {						throw new SQLException(Messages.getString(								"ResultSet.Bad_format_for_BigDecimal",								new Object[] { new Integer(columnIndex),										stringVal }),								SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$					}				}			}			return null;		}		return getNativeBigDecimal(columnIndex, scale);	}	/**	 * JDBC 2.0 Get the value of a column in the current row as a	 * java.math.BigDecimal object.	 * 	 * @param columnName	 *            the name of the column to retrieve the value from	 * 	 * @return the BigDecimal value in the column	 * 	 * @throws SQLException	 *             if an error occurs	 */	public BigDecimal getBigDecimal(String columnName) throws SQLException {		return getBigDecimal(findColumn(columnName));	}	/**	 * DOCUMENT ME!	 * 	 * @param columnName	 *            DOCUMENT ME!	 * @param scale	 *            DOCUMENT ME!	 * 	 * @return DOCUMENT ME!	 * 	 * @throws SQLException	 *             DOCUMENT ME!	 * 	 * @deprecated	 */	public BigDecimal getBigDecimal(String columnName, int scale)			throws SQLException {		return getBigDecimal(findColumn(columnName), scale);	}	private final BigDecimal getBigDecimalFromString(String stringVal,			int columnIndex, int scale) throws SQLException {		BigDecimal bdVal;		if (stringVal != null) {			if (stringVal.length() == 0) {				bdVal = new BigDecimal(convertToZeroWithEmptyCheck());				return bdVal;			}			try {				try {					return new BigDecimal(stringVal).setScale(scale);				} catch (ArithmeticException ex) {					try {						return new BigDecimal(stringVal).setScale(scale,								BigDecimal.ROUND_HALF_UP);					} catch (ArithmeticException arEx) {						throw new SQLException(								Messages										.getString("ResultSet.Bad_format_for_BigDecimal____166") //$NON-NLS-1$										+ stringVal										+ Messages												.getString("ResultSet.___in_column__167")										+ columnIndex + "(" //$NON-NLS-1$										+ this.fields[columnIndex - 1] + ").",								SQLError.SQL_STATE_ILLEGAL_ARGUMENT);					}				}			} catch (NumberFormatException ex) {				throw new SQLException(						Messages								.getString("ResultSet.Bad_format_for_BigDecimal____166") //$NON-NLS-1$								+ stringVal								+ Messages										.getString("ResultSet.___in_column__167")								+ columnIndex + "(" //$NON-NLS-1$								+ this.fields[columnIndex - 1] + ").",						SQLError.SQL_STATE_ILLEGAL_ARGUMENT);			}		}		return null;	}	/**	 * A column value can also be retrieved as a binary strea. This method is	 * suitable for retrieving LONGVARBINARY values.	 * 	 * @param columnIndex	 *            the first column is 1, the second is 2...	 * 	 * @return a Java InputStream that delivers the database column value as a	 *         stream of bytes. If the value is SQL NULL, then the result is	 *         null	 * 	 * @exception SQLException	 *                if a database access error occurs	 * 	 * @see getAsciiStream	 * @see getUnicodeStream	 */	public InputStream getBinaryStream(int columnIndex) throws SQLException {		checkRowPos();		if (!this.isBinaryEncoded) {			byte[] b = getBytes(columnIndex);			if (b != null) {				return new ByteArrayInputStream(b);			}			return null;		}		return getNativeBinaryStream(columnIndex);	}	/**	 * DOCUMENT ME!	 * 	 * @param columnName	 *            DOCUMENT ME!	 * 	 * @return DOCUMENT ME!	 * 	 * @throws SQLException	 *             DOCUMENT ME!	 */	public InputStream getBinaryStream(String columnName) throws SQLException {		return getBinaryStream(findColumn(columnName));	}	/**	 * JDBC 2.0 Get a BLOB column.	 * 	 * @param columnIndex	 *            the first column is 1, the second is 2, ...	 * 	 * @return an object representing a BLOB	 * 	 * @throws SQLException	 *             if an error occurs.	 */	public java.sql.Blob getBlob(int columnIndex) throws SQLException {		if (!this.isBinaryEncoded) {			checkRowPos();			if ((columnIndex < 1) || (columnIndex > this.fields.length)) {				throw new SQLException(Messages.getString(						"ResultSet.Column_Index_out_of_range", new Object[] {								new Integer(columnIndex),								new Integer(this.fields.length) }),						SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$			}			try {				if (this.thisRow[columnIndex - 1] == null) {					this.wasNullFlag = true;				} else {					this.wasNullFlag = false;				}			} catch (NullPointerException ex) {				this.wasNullFlag = true;			}			if (this.wasNullFlag) {				return null;			}			if (!this.connection.getEmulateLocators()) {				return new Blob((byte[]) this.thisRow[columnIndex - 1]);			}			return new BlobFromLocator(this, columnIndex);		}		return getNativeBlob(columnIndex);	}	/**	 * JDBC 2.0 Get a BLOB column.	 * 	 * @param colName	 *            the column name	 * 	 * @return an object representing a BLOB	 * 	 * @throws SQLException	 *             if an error occurs.	 */	public java.sql.Blob getBlob(String colName) throws SQLException {		return getBlob(findColumn(colName));	}	/**	 * Get the value of a column in the current row as a Java boolean	 * 	 * @param columnIndex	 *            the first column is 1, the second is 2...	 * 	 * @return the column value, false for SQL NULL	 * 	 * @exception SQLException	 *                if a database access error occurs	 */	public boolean getBoolean(int columnIndex) throws SQLException {		if (!this.isBinaryEncoded) {			checkColumnBounds(columnIndex);			//			// MySQL 5.0 and newer have an actual BIT type,			// so we need to check for that here...			//			int columnIndexMinusOne = columnIndex - 1;			Field field = this.fields[columnIndexMinusOne];			if (field.getMysqlType() == MysqlDefs.FIELD_TYPE_BIT) {				if (this.thisRow[columnIndexMinusOne] == null) {					this.wasNullFlag = true;					return false;				}				this.wasNullFlag = false;				if (((byte[]) this.thisRow[columnIndexMinusOne]).length == 0) {					return false;				}				byte boolVal = ((byte[]) this.thisRow[columnIndexMinusOne])[0];				return (boolVal > 0);			}			String stringVal = getString(columnIndex);			if ((stringVal != null) && (stringVal.length() > 0)) {				int c = Character.toLowerCase(stringVal.charAt(0));				return ((c == 't') || (c == 'y') || (c == '1') || stringVal						.equals("-1"));			}			return false;		}		return getNativeBoolean(columnIndex);	}	/**	 * DOCUMENT ME!	 * 	 * @param columnName	 *            DOCUMENT ME!	 * 	 * @return DOCUMENT ME!	 * 	 * @throws SQLException	 *             DOCUMENT ME!	 */	public boolean getBoolean(String columnName) throws SQLException {		return getBoolean(findColumn(columnName));	}	private final boolean getBooleanFromString(String stringVal, int columnIndex)			throws SQLException {		if ((stringVal != null) && (stringVal.length() > 0)) {			int c = Character.toLowerCase(stringVal.charAt(0));			return ((c == 't') || (c == 'y') || (c == '1') || stringVal					.equals("-1"));		}		return false;	}	/**	 * Get the value of a column in the current row as a Java byte.	 * 	 * @param columnIndex	 *            the first column is 1, the second is 2,...	 * 	 * @return the column value; 0 if SQL NULL	 * 	 * @exception SQLException	 *                if a database access error occurs	 */	public byte getByte(int columnIndex) throws SQLException {		if (!this.isBinaryEncoded) {			String stringVal = getString(columnIndex);			if (this.wasNullFlag || (stringVal == null)) {				return 0;			}			return getByteFromString(stringVal, columnIndex);		}		return getNativeByte(columnIndex);	}	/**	 * DOCUMENT ME!	 * 	 * @param columnName	 *            DOCUMENT ME!	 * 

⌨️ 快捷键说明

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