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

📄 resultset.java

📁 mysql的jdbc驱动
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
				if (stringVal.length() < 10) {					throw new SQLException(Messages.getString(							"ResultSet.Bad_format_for_Date", new Object[] {									stringVal, new Integer(columnIndex) }),							SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$				}				year = Integer.parseInt(stringVal.substring(0, 4));				month = Integer.parseInt(stringVal.substring(5, 7));				day = Integer.parseInt(stringVal.substring(8, 10));			}			return fastDateCreate(null, year, month, day);		} catch (SQLException sqlEx) {			throw sqlEx; // don't re-wrap		} catch (Exception e) {			throw new SQLException(Messages.getString(					"ResultSet.Bad_format_for_Date", new Object[] { stringVal,							new Integer(columnIndex) }),					SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$		}	}	private synchronized TimeZone getDefaultTimeZone() {		if (this.defaultTimeZone == null) {			this.defaultTimeZone = TimeZone.getDefault();		}		return this.defaultTimeZone;	}	/**	 * Get the value of a column in the current row as a Java double.	 * 	 * @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 double getDouble(int columnIndex) throws SQLException {		if (!this.isBinaryEncoded) {			return getDoubleInternal(columnIndex);		}		return getNativeDouble(columnIndex);	}	/**	 * DOCUMENT ME!	 * 	 * @param columnName	 *            DOCUMENT ME!	 * 	 * @return DOCUMENT ME!	 * 	 * @throws SQLException	 *             DOCUMENT ME!	 */	public double getDouble(String columnName) throws SQLException {		return getDouble(findColumn(columnName));	}	private final double getDoubleFromString(String stringVal, int columnIndex)			throws SQLException {		return getDoubleInternal(stringVal, columnIndex);	}	/**	 * Converts a string representation of a number to a double. Need a faster	 * way to do this.	 * 	 * @param colIndex	 *            the 1-based index of the column to retrieve a double from.	 * 	 * @return the double value represented by the string in buf	 * 	 * @throws SQLException	 *             if an error occurs	 */	protected double getDoubleInternal(int colIndex) throws SQLException {		return getDoubleInternal(getString(colIndex), colIndex);	}	/**	 * Converts a string representation of a number to a double. Need a faster	 * way to do this.	 * 	 * @param stringVal	 *            the double as a String	 * @param colIndex	 *            the 1-based index of the column to retrieve a double from.	 * 	 * @return the double value represented by the string in buf	 * 	 * @throws SQLException	 *             if an error occurs	 */	protected double getDoubleInternal(String stringVal, int colIndex)			throws SQLException {		try {			if ((stringVal == null)) {				return 0;			}			if (stringVal.length() == 0) {				return convertToZeroWithEmptyCheck();			}			double d = Double.parseDouble(stringVal);			if (this.useStrictFloatingPoint) {				// Fix endpoint rounding precision loss in MySQL server				if (d == 2.147483648E9) {					// Fix Odd end-point rounding on MySQL					d = 2.147483647E9;				} else if (d == 1.0000000036275E-15) {					// Fix odd end-point rounding on MySQL					d = 1.0E-15;				} else if (d == 9.999999869911E14) {					d = 9.99999999999999E14;				} else if (d == 1.4012984643248E-45) {					d = 1.4E-45;				} else if (d == 1.4013E-45) {					d = 1.4E-45;				} else if (d == 3.4028234663853E37) {					d = 3.4028235E37;				} else if (d == -2.14748E9) {					d = -2.147483648E9;				} else if (d == 3.40282E37) {					d = 3.4028235E37;				}			}			return d;		} catch (NumberFormatException e) {			throw new SQLException(Messages.getString(					"ResultSet.Bad_format_for_number", new Object[] {							stringVal, new Integer(colIndex) }),					SQLError.SQL_STATE_ILLEGAL_ARGUMENT);		}	}	/**	 * JDBC 2.0 Returns the fetch direction for this result set.	 * 	 * @return the fetch direction for this result set.	 * 	 * @exception SQLException	 *                if a database-access error occurs	 */	public int getFetchDirection() throws SQLException {		return this.fetchDirection;	}	/**	 * JDBC 2.0 Return the fetch size for this result set.	 * 	 * @return the fetch size for this result set.	 * 	 * @exception SQLException	 *                if a database-access error occurs	 */	public int getFetchSize() throws SQLException {		return this.fetchSize;	}	/**	 * Returns the first character of the query that this result set was created	 * from.	 * 	 * @return the first character of the query...uppercased	 */	protected char getFirstCharOfQuery() {		return this.firstCharOfQuery;	}	/**	 * Get the value of a column in the current row as a Java float.	 * 	 * @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 float getFloat(int columnIndex) throws SQLException {		if (!this.isBinaryEncoded) {			String val = null;			val = getString(columnIndex);			return getFloatFromString(val, columnIndex);		}		return getNativeFloat(columnIndex);	}	/**	 * DOCUMENT ME!	 * 	 * @param columnName	 *            DOCUMENT ME!	 * 	 * @return DOCUMENT ME!	 * 	 * @throws SQLException	 *             DOCUMENT ME!	 */	public float getFloat(String columnName) throws SQLException {		return getFloat(findColumn(columnName));	}	private final float getFloatFromString(String val, int columnIndex)			throws SQLException {		try {			if ((val != null)) {				if (val.length() == 0) {					return convertToZeroWithEmptyCheck();				}				float f = Float.parseFloat(val);				if (this.connection.getJdbcCompliantTruncation()) {					if (f == Float.MIN_VALUE || f == Float.MAX_VALUE) {						double valAsDouble = Double.parseDouble(val);						if (valAsDouble < Float.MIN_VALUE								|| valAsDouble > Float.MAX_VALUE) {							throwRangeException(String.valueOf(valAsDouble),									columnIndex, Types.FLOAT);						}					}				}				return f;			}			return 0; // for NULL		} catch (NumberFormatException nfe) {			try {				double valAsDouble = Double.parseDouble(val);				if (this.connection.getJdbcCompliantTruncation()) {					if (valAsDouble < Float.MIN_VALUE							|| valAsDouble > Float.MAX_VALUE) {						throwRangeException(String.valueOf(valAsDouble),								columnIndex, Types.FLOAT);					}				}				return (float) valAsDouble;			} catch (NumberFormatException newNfe) {				; // ignore, it's not a number			}			throw new SQLException(					Messages							.getString("ResultSet.Invalid_value_for_getFloat()_-____200")							+ val //$NON-NLS-1$							+ Messages.getString("ResultSet.___in_column__201")							+ columnIndex, SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$		}	}	/**	 * Get the value of a column in the current row as a Java int.	 * 	 * @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 int getInt(int columnIndex) throws SQLException {		if (!this.isBinaryEncoded) {			if (this.connection.getUseFastIntParsing()) {				checkRowPos();				try {					if (this.thisRow[columnIndex - 1] == null) {						this.wasNullFlag = true;					} else {						this.wasNullFlag = false;					}				} catch (NullPointerException E) {					this.wasNullFlag = true;				} catch (ArrayIndexOutOfBoundsException aioobEx) {					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$				}				if (this.wasNullFlag) {					return 0;				}				byte[] intAsBytes = (byte[]) this.thisRow[columnIndex - 1];				if (intAsBytes.length == 0) {					return convertToZeroWithEmptyCheck();				}				boolean needsFullParse = false;				for (int i = 0; i < intAsBytes.length; i++) {					if (((char) intAsBytes[i] == 'e')							|| ((char) intAsBytes[i] == 'E')) {						needsFullParse = true;						break;					}				}				if (!needsFullParse) {					try {						return parseIntWithOverflowCheck(columnIndex,								intAsBytes, null);					} catch (NumberFormatException nfe) {						try {							return parseIntAsDouble(columnIndex, new String(									intAsBytes));						} catch (NumberFormatException newNfe) {							; // ignore, it's not a number						}						throw new SQLException(								Messages										.getString("ResultSet.Invalid_value_for_getInt()_-____74")										+ new String(intAsBytes) //$NON-NLS-1$										+ "'",								SQLError.SQL_STATE_ILLEGAL_ARGUMENT);					}				}			}			String val = null;			try {				val = getString(columnIndex);				if ((val != null)) {					if (val.length() == 0) {						return convertToZeroWithEmptyCheck();					}					if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)							&& (val.indexOf(".") == -1)) {						return Integer.parseInt(val);					}					// Convert floating point					return parseIntAsDouble(columnIndex, val);				}				return 0;			} catch (NumberFormatException nfe) {				try {					return parseIntAsDouble(columnIndex, val);				} catch (NumberFormatException newNfe) {					; // ignore, it's not a number				}				throw new SQLException(						Messages								.getString("ResultSet.Invalid_value_for_getInt()_-____74")								+ val //$NON-NLS-1$								+ "'", SQLError.SQL_STATE_ILLEGAL_ARGUMENT);			}		}		return getNativeInt(columnIndex);	}	/**	 * DOCUMENT ME!	 * 	 * @param columnName	 *            DOCUMENT ME!	 * 	 * @return DOCUMENT ME!	 * 	 * @throws SQLException	 *             DOCUMENT ME!	 */	public int getInt(String columnName) throws SQLException {		return getInt(findColumn(columnName));	}	private final int getIntFromString(String val, int columnIndex)			throws SQLException {		try {			if ((val != null)) {				if (val.length() == 0) {					return convertToZeroWithEmptyCheck();				}				if ((val.indexOf("e") == -1) && (val.indexOf("E") == -1)						&& (val.indexOf(".") == -1)) {					int valueAsInt = Integer.parseInt(val);					if (this.connection.getJdbcCompliantTruncation()) {						if (valueAsInt == Integer.MIN_VALUE								|| valueAsInt == Integer.MAX_VALUE) {							long valueAsLong = Long.parseLong(val);							if (valueAsLong < Integer.MIN_VALUE									|| valueAsLong > Integer.MAX_VALUE) {								throwRangeException(										String.valueOf(valueAsLong),										columnIndex, Types.INTEGER);							}						}					}					return valueAsInt;				}				// Convert floating point				double valueAsDouble = Double.parseDouble(val);				if (this.connection.getJdbcCompliantTruncation()) {					if (valueAsDouble < Integer.MIN_VALUE							|| valueAsDouble > Integer.MAX_VALUE) {						throwRangeException(String.valueOf(valueAsDouble),								columnIndex, Types.INTEGER);					}				}				return (int) valueAsDouble;			}			return 0; // for NULL		} catch (NumberFormatException nfe) {			try {				double valueAsDouble = Double.parseDouble(val);				if (this.connection.getJdbcCompliantTruncation()) {					if (valueAsDouble < Integer.MIN_VALUE							|| valueAsDouble > Integer.MAX_VALUE) {						throwRangeException(String.valueOf(valueAsDouble),								columnIndex, Types.INTEGER);					}				}				return (int) valueAsDouble;			} catch (NumberFormatException newNfe) {				; // ignore, it's not a number			}			throw new SQLException(Messages					.getString("ResultSet.Invalid_value_for_getInt()_-____206")					+ val //$NON-NLS-1$					+ Messages.getString("ResultSet.___in_column__207")					+ columnIndex, SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$		}	}	/**	 * Get the value of a column in the current row as a Java long.	 * 	 * @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 long getLong(int columnIndex) throws SQLException {		if (!this.isBinaryEncoded) {			if (this.connection.getUseFastIntParsing()) {				checkRowPos();				try {					if (this.thisRow[columnIndex - 1] == null) {						this.wasNullFlag = true;					} else {						this.wasNullFlag = false;					}				} catch (NullPointerExcept

⌨️ 快捷键说明

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