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

📄 statement.java

📁 mysql的jdbc驱动
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
			if (!Character.isDigit(c)) {				break;			}			recordsBuf.append(c);		}		recordsCount = Integer.parseInt(recordsBuf.toString());		StringBuffer duplicatesBuf = new StringBuffer();		for (; i < length; i++) {			c = serverInfo.charAt(i);			if (Character.isDigit(c)) {				break;			}		}		duplicatesBuf.append(c);		i++;		for (; i < length; i++) {			c = serverInfo.charAt(i);			if (!Character.isDigit(c)) {				break;			}			duplicatesBuf.append(c);		}		duplicatesCount = Integer.parseInt(duplicatesBuf.toString());		return recordsCount - duplicatesCount;	}	/**	 * getResultSet returns the current result as a ResultSet. It should only be	 * called once per result.	 * 	 * @return the current result set; null if there are no more	 * 	 * @exception SQLException	 *                if a database access error occurs (why?)	 */	public synchronized java.sql.ResultSet getResultSet() throws SQLException {		return ((this.results != null) && this.results.reallyResult()) ? (java.sql.ResultSet) this.results				: null;	}	/**	 * JDBC 2.0 Determine the result set concurrency.	 * 	 * @return CONCUR_UPDATABLE or CONCUR_READONLY	 * 	 * @throws SQLException	 *             if an error occurs	 */	public synchronized int getResultSetConcurrency() throws SQLException {		return this.resultSetConcurrency;	}	/**	 * @see Statement#getResultSetHoldability()	 */	public int getResultSetHoldability() throws SQLException {		return java.sql.ResultSet.HOLD_CURSORS_OVER_COMMIT;	}	/**	 * JDBC 2.0 Determine the result set type.	 * 	 * @return the ResultSet type (SCROLL_SENSITIVE or SCROLL_INSENSITIVE)	 * 	 * @throws SQLException	 *             if an error occurs.	 */	public synchronized int getResultSetType() throws SQLException {		return this.resultSetType;	}	/**	 * getUpdateCount returns the current result as an update count, if the	 * result is a ResultSet or there are no more results, -1 is returned. It	 * should only be called once per result.	 * 	 * @return the current result as an update count.	 * 	 * @exception SQLException	 *                if a database access error occurs	 */	public synchronized int getUpdateCount() throws SQLException {		if (this.results == null) {			return -1;		}		if (this.results.reallyResult()) {			return -1;		}		int truncatedUpdateCount = 0;		if (this.results.getUpdateCount() > Integer.MAX_VALUE) {			truncatedUpdateCount = Integer.MAX_VALUE;		} else {			truncatedUpdateCount = (int) this.results.getUpdateCount();		}		return truncatedUpdateCount;	}	/**	 * The first warning reported by calls on this Statement is returned. A	 * Statement's execute methods clear its java.sql.SQLWarning chain.	 * Subsequent Statement warnings will be chained to this	 * java.sql.SQLWarning.	 * 	 * <p>	 * The Warning chain is automatically cleared each time a statement is	 * (re)executed.	 * </p>	 * 	 * <p>	 * <B>Note:</B> If you are processing a ResultSet then any warnings	 * associated with ResultSet reads will be chained on the ResultSet object.	 * </p>	 * 	 * @return the first java.sql.SQLWarning or null	 * 	 * @exception SQLException	 *                if a database access error occurs	 */	public synchronized java.sql.SQLWarning getWarnings() throws SQLException {		checkClosed();				if (this.connection.versionMeetsMinimum(4, 1, 0)) {			SQLWarning pendingWarningsFromServer = SQLError					.convertShowWarningsToSQLWarnings(this.connection);			if (this.warningChain != null) {				this.warningChain.setNextWarning(pendingWarningsFromServer);			} else {				this.warningChain = pendingWarningsFromServer;			}			return this.warningChain;		}		return this.warningChain;	}	/**	 * Caches CachedResultSetMetaData that has been placed in the cache using	 * the given SQL as a key.	 * 	 * @param sql	 *            DOCUMENT ME!	 * @param cachedMetaData	 *            DOCUMENT ME!	 * @param resultSet	 *            DOCUMENT ME!	 * 	 * @throws SQLException	 *             DOCUMENT ME!	 */	protected void initializeResultsMetadataFromCache(String sql,			CachedResultSetMetaData cachedMetaData, ResultSet resultSet)			throws SQLException {		synchronized (resultSet) {			if (cachedMetaData == null) {				// read from results				cachedMetaData = new CachedResultSetMetaData();				cachedMetaData.fields = this.results.fields;				// assume that users will use named-based				// lookups				resultSet.buildIndexMapping();				cachedMetaData.columnNameToIndex = resultSet.columnNameToIndex;				cachedMetaData.fullColumnNameToIndex = resultSet.fullColumnNameToIndex;				cachedMetaData.metadata = resultSet.getMetaData();				if (this.resultSetMetadataCache == null) {					this.resultSetMetadataCache = new LRUCache(this.connection							.getMetadataCacheSize());				}				this.resultSetMetadataCache.put(sql, cachedMetaData);			} else {				// initialize results from cached data				resultSet.fields = cachedMetaData.fields;				resultSet.columnNameToIndex = cachedMetaData.columnNameToIndex;				resultSet.fullColumnNameToIndex = cachedMetaData.fullColumnNameToIndex;				resultSet.hasBuiltIndexMapping = true;				// results.resultSetMetaData = cachedMetaData.metadata;			}		}	}	/**	 * Closes this statement, and frees resources.	 * 	 * @param calledExplicitly	 *            was this called from close()?	 * 	 * @throws SQLException	 *             if an error occurs	 */	protected void realClose(boolean calledExplicitly) throws SQLException {		if (this.isClosed) {			return;		}		if (this.useUsageAdvisor) {			if (!calledExplicitly) {				String message = Messages.getString("Statement.63") //$NON-NLS-1$						+ Messages.getString("Statement.64"); //$NON-NLS-1$				this.eventSink.consumeEvent(new ProfilerEvent(						ProfilerEvent.TYPE_WARN, "", //$NON-NLS-1$						this.currentCatalog, this.connection.getId(), this								.getId(), -1, System.currentTimeMillis(), 0,						null, this.pointOfOrigin, message));			}		}		if (this.results != null) {			if (this.connection != null					&& !this.connection.getHoldResultsOpenOverStatementClose()) {				try {					this.results.close();				} catch (Exception ex) {					;				}			}		}		if (this.connection != null) {			if (this.maxRowsChanged) {				this.connection.unsetMaxRows(this);			}			if (!this.connection.getDontTrackOpenResources()) {				this.connection.unregisterStatement(this);			}		}		this.closeAllOpenResults();		this.results = null;		this.connection = null;		this.warningChain = null;		this.openResults = null;		this.isClosed = true;	}	/**	 * setCursorName defines the SQL cursor name that will be used by subsequent	 * execute methods. This name can then be used in SQL positioned	 * update/delete statements to identify the current row in the ResultSet	 * generated by this statement. If a database doesn't support positioned	 * update/delete, this method is a no-op.	 * 	 * <p>	 * <b>Note:</b> This MySQL driver does not support cursors.	 * </p>	 * 	 * @param name	 *            the new cursor name	 * 	 * @exception SQLException	 *                if a database access error occurs	 */	public void setCursorName(String name) throws SQLException {		// No-op	}	/**	 * If escape scanning is on (the default), the driver will do escape	 * substitution before sending the SQL to the database.	 * 	 * @param enable	 *            true to enable; false to disable	 * 	 * @exception SQLException	 *                if a database access error occurs	 */	public synchronized void setEscapeProcessing(boolean enable)			throws SQLException {		this.doEscapeProcessing = enable;	}	/**	 * JDBC 2.0 Give a hint as to the direction in which the rows in a result	 * set will be processed. The hint applies only to result sets created using	 * this Statement object. The default value is ResultSet.FETCH_FORWARD.	 * 	 * @param direction	 *            the initial direction for processing rows	 * 	 * @exception SQLException	 *                if a database-access error occurs or direction is not one	 *                of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or	 *                ResultSet.FETCH_UNKNOWN	 */	public void setFetchDirection(int direction) throws SQLException {		switch (direction) {		case java.sql.ResultSet.FETCH_FORWARD:		case java.sql.ResultSet.FETCH_REVERSE:		case java.sql.ResultSet.FETCH_UNKNOWN:			break;		default:			throw new SQLException(Messages.getString("Statement.5"), //$NON-NLS-1$					SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$		}	}	/**	 * JDBC 2.0 Give the JDBC driver a hint as to the number of rows that should	 * be fetched from the database when more rows are needed. The number of	 * rows specified only affects result sets created using this statement. If	 * the value specified is zero, then the hint is ignored. The default value	 * is zero.	 * 	 * @param rows	 *            the number of rows to fetch	 * 	 * @exception SQLException	 *                if a database-access error occurs, or the condition 0	 *                &lt;= rows &lt;= this.getMaxRows() is not satisfied.	 */	public synchronized void setFetchSize(int rows) throws SQLException {		if (((rows < 0) && (rows != Integer.MIN_VALUE))				|| ((this.maxRows != 0) && (this.maxRows != -1) && (rows > this						.getMaxRows()))) {			throw new SQLException(Messages.getString("Statement.7"), //$NON-NLS-1$					SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$ //$NON-NLS-2$		}		this.fetchSize = rows;	}	/**	 * Sets the maxFieldSize	 * 	 * @param max	 *            the new max column size limit; zero means unlimited	 * 	 * @exception SQLException	 *                if size exceeds buffer size	 */	public synchronized void setMaxFieldSize(int max) throws SQLException {		if (max < 0) {			throw new SQLException(Messages.getString("Statement.11"), //$NON-NLS-1$					SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$		}		int maxBuf = (this.connection != null) ? this.connection				.getMaxAllowedPacket() : MysqlIO.getMaxBuf();		if (max > maxBuf) {			throw new SQLException(Messages.getString("Statement.13", //$NON-NLS-1$					new Object[] { new Long(maxBuf) }), //$NON-NLS-1$					SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$		}		this.maxFieldSize = max;	}	/**	 * Set the maximum number of rows	 * 	 * @param max	 *            the new max rows limit; zero means unlimited	 * 	 * @exception SQLException	 *                if a database access error occurs	 * 	 * @see getMaxRows	 */	public synchronized void setMaxRows(int max) throws SQLException {		if ((max > MysqlDefs.MAX_ROWS) || (max < 0)) {			throw new SQLException(					Messages.getString("Statement.15") + max //$NON-NLS-1$							+ " > " //$NON-NLS-1$ //$NON-NLS-2$							+ MysqlDefs.MAX_ROWS + ".", SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$ //$NON-NLS-2$		}		if (max == 0) {			max = -1;		}		this.maxRows = max;		this.maxRowsChanged = true;		if (this.maxRows == -1) {			this.connection.unsetMaxRows(this);			this.maxRowsChanged = false;		} else {			// Most people don't use setMaxRows()			// so don't penalize them			// with the extra query it takes			// to do it efficiently unless we need			// to.			this.connection.maxRowsChanged(this);		}	}	/**	 * Sets the queryTimeout limit	 * 	 * @param seconds -	 *            the new query timeout limit in seconds	 * 	 * @exception SQLException	 *                if a database access error occurs	 */	public void setQueryTimeout(int seconds) throws SQLException {		if (seconds < 0) {			throw new SQLException(Messages.getString("Statement.21"), //$NON-NLS-1$					SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$		}		this.timeout = seconds;	}	/**	 * Sets the concurrency for result sets generated by this statement	 * 	 * @param concurrencyFlag	 *            DOCUMENT ME!	 */	synchronized void setResultSetConcurrency(int concurrencyFlag) {		this.resultSetConcurrency = concurrencyFlag;	}	/**	 * Sets the result set type for result sets generated by this statement	 * 	 * @param typeFlag	 *            DOCUMENT ME!	 */	synchronized void setResultSetType(int typeFlag) {		this.resultSetType = typeFlag;	}}

⌨️ 快捷键说明

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