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

📄 monetresultset.java

📁 这个是内存数据库的客户端
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		throw new SQLException("No such columnname: " + columnName);	}	/**	 * Moves the cursor to the first row in this ResultSet object.	 *	 * @return true if the cursor is on a valid row; false if there are no rows	 *         in the result set	 * @throws SQLException - if a database access error occurs or the result	 *         set type is TYPE_FORWARD_ONLY	 */	public boolean first() throws SQLException {		return(absolute(1));	}	public Array getArray(int i) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public Array getArray(String colName) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	/* Mapi doesn't allow something for streams at the moment, thus all	   not implemented for now */	public InputStream getAsciiStream(int columnIndex) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public InputStream getAsciiStream(String columnName) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public InputStream getBinaryStream(int columnIndex) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public InputStream getBinaryStream(String columnName) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public InputStream getUnicodeStream(int columnIndex) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public InputStream getUnicodeStream(String columnName) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public Blob getBlob(int i) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public Blob getBlob(String colName) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public Reader getCharacterStream(int columnIndex) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public Reader getCharacterStream(String columnName) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	/**	 * Retrieves the value of the designated column in the current row	 * of this ResultSet object as a Clob object in the	 * Java programming language.	 *	 * @param i the first column is 1, the second is 2, ...	 * @return a Clob object representing the SQL CLOB value in the	 *         specified column	 * @throws SQLException if a database access error occurs	 */	public Clob getClob(int i) throws SQLException {		String tmp = getString(i);		if (tmp == null) {			return(null);		} else {			return(new MonetClob(tmp));		}	}	/**	 * Retrieves the value of the designated column in the current row	 * of this ResultSet object as a Clob object in the	 * Java programming language.	 *	 * @param colName the name of the column from which to retrieve	 *        the value	 * @return a Clob object representing the SQL CLOB value in the	 *         specified column	 * @throws SQLException if a database access error occurs	 */	public Clob getClob(String colName) throws SQLException {		return(getClob(findColumn(colName)));	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a java.math.BigDecimal with full precision.	 *	 * @param columnIndex the first column is 1, the second is 2, ...	 * @return the column value (full precision); if the value is SQL NULL,	 *         the value returned is null in the Java programming language.	 * @throws SQLException if a database access error occurs	 */	public BigDecimal getBigDecimal(int columnIndex) throws SQLException {		String decimal = getString(columnIndex);		if (decimal == null) {			return(null);		} else {			try {				return(new BigDecimal(decimal));			} catch (NumberFormatException e) {				return(new BigDecimal("0"));			}		}	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a java.math.BigDecimal with full precision.	 *	 * @param columnIndex the first column is 1, the second is 2, ...	 * @param scale the number of digits to the right of the decimal point	 * @return the column value (full precision); if the value is SQL NULL,	 *         the value returned is null in the Java programming language.	 * @throws SQLException if a database access error occurs	 */	public BigDecimal getBigDecimal(int columnIndex, int scale)		throws SQLException	{		String decimal = getString(columnIndex);		if (decimal == null) {			return(null);		} else {			BigDecimal bd;			try {				bd = new BigDecimal(decimal);			} catch (NumberFormatException e) {				bd = new BigDecimal("0");			}			bd.setScale(scale);			return(bd);		}	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a java.math.BigDecimal with full precision.	 *	 * @param columnName the SQL name of the column	 * @return the column value (full precision); if the value is SQL NULL,	 *         the value returned is null in the Java programming language.	 * @throws SQLException if a database access error occurs	 */	public BigDecimal getBigDecimal(String columnName) throws SQLException {		return(getBigDecimal(findColumn(columnName)));	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a java.math.BigDecimal with full precision.	 *	 * @param columnName the SQL name of the column	 * @param scale the number of digits to the right of the decimal point	 * @return the column value (full precision); if the value is SQL NULL,	 *         the value returned is null in the Java programming language.	 * @throws SQLException if a database access error occurs	 */	public BigDecimal getBigDecimal(String columnName, int scale)		throws SQLException	{		return(getBigDecimal(findColumn(columnName), scale));	}	// See Sun JDBC Specification 3.0 Table B-6	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a boolean in the Java programming language.	 *	 * @param columnIndex the first column is 1, the second is 2, ...	 * @return the column value; if the value is SQL NULL, the value returned	 *         is false	 * @throws SQLException if there is no such column	 */	public boolean getBoolean(int columnIndex) throws SQLException{		int dataType = MonetDriver.getJavaType(types[columnIndex - 1]);		if (dataType == Types.TINYINT ||			dataType == Types.SMALLINT ||			dataType == Types.INTEGER ||			dataType == Types.BIGINT)		{			if (getLong(columnIndex) == 0L) {				return(false);			} else {				return(true);			}		} else if (dataType == Types.REAL ||			dataType == Types.FLOAT ||			dataType == Types.DOUBLE)		{			if (getDouble(columnIndex) == 0.0) {				return(false);			} else {				return(true);			}		} else if (dataType == Types.DECIMAL ||			dataType == Types.NUMERIC)		{			if (getBigDecimal(columnIndex).compareTo(new BigDecimal(0.0)) == 0) {				return(false);			} else {				return(true);			}		} else if (dataType == Types.BIT ||			dataType == Types.BOOLEAN ||			dataType == Types.CHAR ||			dataType == Types.VARCHAR ||			dataType == Types.LONGVARCHAR)		{			return((Boolean.valueOf(getString(columnIndex))).booleanValue());		} else {			throw new SQLException("Conversion from " + types[columnIndex - 1] + " to boolean type not supported");		}	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a boolean in the Java programming language.	 *	 * @param columnName the SQL name of the column	 * @return the column value; if the value is SQL NULL, the value returned	 *         is false	 * @throws SQLException if the ResultSet object does not contain columnName	 */	public boolean getBoolean(String columnName) throws SQLException {		return(getBoolean(findColumn(columnName)));	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a byte in the Java programming language.	 *	 * @param columnIndex the first column is 1, the second is 2, ...	 * @return the column value; if the value is SQL NULL, the value returned	 *         is 0	 * @throws SQLException if a database access error occurs	 */	public byte getByte(int columnIndex) throws SQLException {		String bytes = getString(columnIndex);		if (bytes == null || bytes.length() == 0) {			return((byte)0);		} else {			return(bytes.getBytes()[0]);		}	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a byte in the Java programming language.	 *	 * @param columnName the SQL name of the column	 * @return the column value; if the value is SQL NULL, the value returned	 *         is 0	 * @throws SQLException if a database access error occurs	 */	public byte getByte(String columnName) throws SQLException {		return(getByte(findColumn(columnName)));	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a byte array in the Java programming language. The	 * bytes represent the raw values returned by the driver.	 * <br /><br />	 * NOTE: Since the mapi protocol is ASCII-based, this method only returns	 *       Java byte representations of Strings, which is nothing more than	 *       an encoding into a sequence of bytes using the platform's default	 *       charset.	 *	 * @param columnIndex the first column is 1, the second is 2, ...	 * @return the column value; if the value is SQL NULL, the value returned	 *         is null	 * @throws SQLException if a database access error occurs	 */	public byte[] getBytes(int columnIndex) throws SQLException {		String bytes = getString(columnIndex);		if (bytes == null) {			return(null);		} else {			return(bytes.getBytes());		}	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a byte array in the Java programming language. The	 * bytes represent the raw values returned by the driver.	 * <br /><br />	 * NOTE: Since the mapi protocol is ASCII-based, this method only returns	 *       Java byte representations of Strings, which is nothing more than	 *       an encoding into a sequence of bytes using the platform's default	 *       charset.	 *	 * @param columnName the SQL name of the column	 * @return the column value; if the value is SQL NULL, the value returned	 *         is null	 * @throws SQLException if a database access error occurs	 */	public byte[] getBytes(String columnName) throws SQLException {		return(getBytes(findColumn(columnName)));	}	/**	 * Retrieves the concurrency mode of this ResultSet object. The concurrency	 * used is determined by the Statement object that created the result set.	 * <br /><br />	 * NOTE: MonetDB only supports read-only result sets, and will always return	 *       ResultSet.CONCUR_READ_ONLY	 *	 * @return the concurrency type, either ResultSet.CONCUR_READ_ONLY or	 *         ResultSet.CONCUR_UPDATABLE	 */	public int getConcurrency() {		return(concurrency);	}	/**	 * Retrieves the name of the SQL cursor used by this ResultSet object.	 * In SQL, a result table is retrieved through a cursor that is named.	 * For MonetDB this is the tableID returned in a resultset header. The	 * current row of a result set can be updated or deleted using a positioned	 * update/delete statement that references the cursor name. To insure that	 * the cursor has the proper isolation level to support update, the	 * cursor's SELECT statement should be of the form SELECT FOR UPDATE. If	 * FOR UPDATE is omitted, the positioned updates may fail.	 * <br /><br />	 * The JDBC API supports this SQL feature by providing the name of the SQL	 * cursor used by a ResultSet object. The current row of a ResultSet object	 * is also the current row of this SQL cursor.	 * <br /><br />	 * Note: If positioned update is not supported, a SQLException is thrown.	 *       MonetDB currently doesn't support updates, so the SQLException is	 *       thrown for now.	 *	 * @return the SQL name for this ResultSet object's cursor	 * @throws SQLException if a database access error occurs	 */	public String getCursorName() throws SQLException {		throw new SQLException("Positioned updates not supported for this " +							   "cursor (" + tableID + ")");		//return("" + tableID);	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a double in the Java programming language.	 *	 * @param columnIndex the first column is 1, the second is 2, ...	 * @return the column value; if the value is SQL NULL, the value returned	 *         is 0	 * @throws SQLException if there is no such column	 */	public double getDouble(int columnIndex) throws SQLException {		double ret = 0;	// note: relaxing by compiler here		String dbl = getString(columnIndex);		if (dbl != null) {			try {				ret = Double.parseDouble(dbl);			} catch (NumberFormatException e) {				// ignore, return the default: 0			}			// do not catch SQLException for it is declared to be thrown		}		return(ret);	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a double in the Java programming language.	 *	 * @param columnName the SQL name of the column	 * @return the column value; if the value is SQL NULL, the value returned	 *         is 0	 * @throws SQLException if the ResultSet object does not contain columnName	 */	public double getDouble(String columnName) throws SQLException {		return(getDouble(findColumn(columnName)));	}	/**	 * Retrieves the fetch direction for this ResultSet object.	 * <b>currently not implemented</b>	 *	 * @return the current fetch direction for this ResultSet object	 */	public int getFetchDirection() {		return(FETCH_FORWARD);	}	/**	 * Retrieves the fetch size for this ResultSet object.	 *	 * @return the current fetch size for this ResultSet object

⌨️ 快捷键说明

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