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

📄 monetresultset.java

📁 这个是内存数据库的客户端
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			public String getCatalogName(int column) throws SQLException {				if (getTableName(column) != "") {					return(getStatement().getConnection().getCatalog());				} else {					return("");				}			}			/**			 * Indicates whether the designated column is definitely not			 * writable.  MonetDB does not support cursor updates, so			 * nothing is writable.			 *			 * @param column the first column is 1, the second is 2, ...			 * @return true if so; false otherwise			 */			public boolean isReadOnly(int column) {				return(true);			}			/**			 * Indicates whether it is possible for a write on the			 * designated column to succeed.			 *			 * @param column the first column is 1, the second is 2, ...			 * @return true if so; false otherwise			 */			public boolean isWritable(int column) {				return(false);			}			/**			 * Indicates whether a write on the designated column will			 * definitely succeed.			 *			 * @param column the first column is 1, the second is 2, ...			 * @return true if so; false otherwise			 */			public boolean isDefinitelyWritable(int column) {				return(false);			}			/**			 * Returns the fully-qualified name of the Java class whose			 * instances are manufactured if the method			 * ResultSet.getObject is called to retrieve a value from			 * the column.  ResultSet.getObject may return a subclass of			 * the class returned by this method.			 *			 * @param column the first column is 1, the second is 2, ...			 * @return the fully-qualified name of the class in the Java			 *         programming language that would be used by the method			 *         ResultSet.getObject to retrieve the value in the			 *         specified column. This is the class name used for custom			 *         mapping.			 * @throws SQLException if there is no such column			 */			public String getColumnClassName(int column) throws SQLException {				try {					return(						getClassForType(							MonetDriver.getJavaType(types[column - 1])						).getName()					);				} catch (IndexOutOfBoundsException e) {					throw new SQLException("No such column " + column);				}			}			/**			 * Gets the designated column's suggested title for use in			 * printouts and displays. This is currently equal to			 * getColumnName().			 *			 * @param column the first column is 1, the second is 2, ...			 * @return the suggested column title			 * @throws SQLException if there is no such column			 */			public String getColumnLabel(int column) throws SQLException {				return(getColumnName(column));			}			/**			 * Gets the designated column's name			 *			 * @param column the first column is 1, the second is 2, ...			 * @return the column name			 * @throws SQLException if there is no such column			 */			public String getColumnName(int column) throws SQLException {				try {					return(columns[column - 1]);				} catch (IndexOutOfBoundsException e) {					throw new SQLException("No such column " + column);				}			}			/**			 * Retrieves the designated column's SQL type.			 *			 * @param column the first column is 1, the second is 2, ...			 * @return SQL type from java.sql.Types			 * @throws SQLException if there is no such column			 */			public int getColumnType(int column) throws SQLException {				String type = getColumnTypeName(column);				return(MonetDriver.getJavaType(type));			}			/**			 * Retrieves the designated column's database-specific type name.			 *			 * @param column the first column is 1, the second is 2, ...			 * @return type name used by the database. If the column type is a			 *         user-defined type, then a fully-qualified type name is			 *         returned.			 * @throws SQLException if there is no such column			 */			public String getColumnTypeName(int column) throws SQLException {				try {					return(types[column - 1]);				} catch (IndexOutOfBoundsException e) {					throw new SQLException("No such column " + column);				}			}			/**			 * Returns the Metadata ResultSet for the given column			 * number of this ResultSet.  If the column was previously			 * requested, a cached ResultSet is returned, otherwise it			 * is fetched using the DatabaseMetaData class.			 *			 * @param column the column index number starting from 1			 * @return Metadata ResultSet			 * @throws SQLException if a database error occurs			 */			private ResultSet getColumnResultSet(int column)				throws SQLException			{				if (column > columns.length || column <= 0) throw					new SQLException("No such column " + column);				if (colrs[column - 1] == null) {					if (dbmd == null)						dbmd = getStatement().getConnection().getMetaData();					ResultSet col = 						dbmd.getColumns(								null, /* this doesn't matter here... */								getSchemaName(column),								getTableName(column),								getColumnName(column)							);					colrs[column - 1] = col;				}				colrs[column - 1].beforeFirst();				return(colrs[column - 1]);			}			protected void finalize() {				for (int i = 0; i < columns.length; i++) {					try {						if (colrs[i] != null) colrs[i].close();					} catch (SQLException e) {						// ignore... perhaps already closed by GC					}				}			}		});	}	/**	 * Gets the value of the designated column in the current row of this	 * ResultSet object as an Object in the Java programming language.	 * <br /><br />	 * This method will return the value of the given column as a Java object.	 * The type of the Java object will be the default Java object type	 * corresponding to the column's SQL type, following the mapping for	 * built-in types specified in the JDBC specification. If the value is	 * an SQL NULL, the driver returns a Java null.	 * <br /><br />	 * This method may also be used to read database-specific abstract data	 * types. In the JDBC 2.0 API, the behavior of method getObject is extended	 * to materialize data of SQL user-defined types. When a column contains a	 * structured or distinct value, the behavior of this method is as if it	 * were a call to: getObject(columnIndex,	 * this.getStatement().getConnection().getTypeMap()).	 *	 * @param columnIndex the first column is 1, the second is 2, ...	 * @return a java.lang.Object holding the column value	 * @throws SQLException if a database access error occurs	 */	public Object getObject(int columnIndex) throws SQLException {		return(getObject(columnIndex, this.getStatement().getConnection().getTypeMap()));	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as an Object in the Java programming language. If the	 * value is an SQL NULL, the driver returns a Java null. This method uses	 * the given Map object for the custom mapping of the SQL structured or	 * distinct type that is being retrieved.	 *	 * @param i the first column is 1, the second is 2, ...	 * @param map a java.util.Map object that contains the mapping from SQL	 *        type names to classes in the Java programming language	 * @return an Object in the Java programming language representing the SQL	 *         value	 * @throws SQLException if a database access error occurs	 */	public Object getObject(int i, Map map) throws SQLException {		if (result[i - 1] == null) {			lastColumnRead = i - 1;			return(null);		}		Class type = getClassForType(MonetDriver.getJavaType(types[i - 1]));				if (type == BigDecimal.class) {			return(getBigDecimal(i));		} else if (type == Boolean.class) {			return(Boolean.valueOf(getBoolean(i)));		} else if (type == Integer.class) {			return(new Integer(getInt(i)));		} else if (type == Long.class) {			return(new Long(getLong(i)));		} else if (type == Float.class) {			return(new Float(getFloat(i)));		} else if (type == Double.class) {			return(new Double(getDouble(i)));		} else if (type == java.sql.Date.class) {			return(getDate(i));		} else if (type == Time.class) {			return(getTime(i));		} else if (type == Timestamp.class) {			return(getTimestamp(i));		} else {			return(getString(i));		}	}	/**	 * Helper method to support the getObject and	 * ResultsetMetaData.getColumnClassName JDBC methods.	 *	 * @param type a value from java.sql.Types	 * @return a Class object from which an instance would be returned	 */	static Class getClassForType(int type) {		/**		 * This switch returns the types as objects according to table B-3 from		 * Sun's JDBC specification 3.0		 */		switch(type) {			case Types.CHAR:			case Types.VARCHAR:			case Types.LONGVARCHAR:				return(String.class);			case Types.NUMERIC:			case Types.DECIMAL:				return(BigDecimal.class);			case Types.BIT: // we don't use type BIT, it's here for completeness			case Types.BOOLEAN:				return(Boolean.class);			case Types.TINYINT:			case Types.SMALLINT:			case Types.INTEGER:				return(Integer.class);			case Types.BIGINT:				return(Long.class);			case Types.REAL:				return(Float.class);			case Types.FLOAT:			case Types.DOUBLE:				return(Double.class);			case Types.DATE:				return(java.sql.Date.class);			case Types.TIME:				return(Time.class);			case Types.TIMESTAMP:				return(Timestamp.class);			// all below are currently not implemented and used			case Types.DISTINCT:			case Types.CLOB:			case Types.BLOB:			case Types.ARRAY:			case Types.STRUCT:			case Types.REF:			case Types.DATALINK:			case Types.OTHER:			case Types.BINARY:			case Types.VARBINARY:			case Types.LONGVARBINARY:			default:				return(String.class);		}	}	/**	 * Gets the value of the designated column in the current row of this	 * ResultSet object as an Object in the Java programming language.	 * <br /><br />	 * This method will return the value of the given column as a Java object.	 * The type of the Java object will be the default Java object type	 * corresponding to the column's SQL type, following the mapping for	 * built-in types specified in the JDBC specification. If the value is an	 * SQL NULL, the driver returns a Java null.	 * <br /><br />	 * This method may also be used to read database-specific abstract data	 * types.	 * <br /><br />	 * In the JDBC 2.0 API, the behavior of the method getObject is extended to	 * materialize data of SQL user-defined types. When a column contains a	 * structured or distinct value, the behavior of this method is as if it	 * were a call to: getObject(columnName,	 * this.getStatement().getConnection().getTypeMap()).	 *	 * @param columnName the SQL name of the column	 * @return a java.lang.Object holding the column value	 * @throws SQLException if a database access error occurs	 */	public Object getObject(String columnName) throws SQLException {		return(getObject(columnName, this.getStatement().getConnection().getTypeMap()));	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as an Object  in the Java programming language. If the	 * value is an SQL NULL, the driver returns a Java null. This method uses	 * the specified Map object for custom mapping if appropriate.	 *	 * @param colName the name of the column from which to retrieve the value	 * @param map a java.util.Map object that contains the mapping from SQL	 *        type names to classes in the Java programming language	 * @return an Object representing the SQL value in the specified column	 * @throws SQLException if a database access error occurs	 */	public Object getObject(String colName, Map map) throws SQLException {		return(getObject(findColumn(colName), map));	}	public Ref getRef(int i) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	public Ref getRef(String colName) throws SQLException { throw new SQLException("Method not implemented yet, sorry!"); }	/**	 * Retrieves the current row number. The first row is number 1, the second	 * number 2, and so on.	 *	 * @return the current row number; 0 if there is no current row	 */	public int getRow() {		return(curRow);	}	/**	 * Retrieves the value of the designated column in the current row of this	 * ResultSet object as a short 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 short getShort(int columnIndex) throws SQLException {		short ret = 0;	// note: relaxing by compiler here		try {			ret = Short.parseShort(getString(columnIndex));		} catch (NumberFormatException e) {			// ignore, return the default: 0		}		// do not catch SQLException for it is declared to be thrown

⌨️ 快捷键说明

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