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

📄 debuggablestatement.java

📁 Local Lucene ==================== Provide geographical based searching to lucene in an efficent ma
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	 */	public void setByte(int parameterIndex, byte x) throws SQLException {		saveObject(parameterIndex, new Byte(x));		ps.setByte(parameterIndex, x);	}	/**	 * Adds byte[] to debug string in parameterIndex position.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setBytes(int parameterIndex, byte[] x) throws SQLException {		saveObject(parameterIndex, (x == null ? "NULL" : "byte[] length="				+ x.length));		ps.setBytes(parameterIndex, x);	}	/**	 * Debug string prints NULL if reader is null, or adds "stream length= " +	 * length.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 * @param length	 *            length of InputStream	 */	public void setCharacterStream(int parameterIndex, Reader reader, int length)			throws SQLException {		saveObject(parameterIndex, (reader == null ? "NULL"				: "<stream length= " + length + ">"));		ps.setCharacterStream(parameterIndex, reader, length);	}	/**	 * Adds name of the object's class type(Clob) to the debug String. If object	 * is null, NULL is added to debug String.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setClob(int i, Clob x) throws SQLException {		saveObject(i, x);		ps.setClob(i, x);	}	public void setCursorName(String name) throws SQLException {		ps.setCursorName(name);	}	/**	 * Debug string displays date in YYYY-MM-DD HH24:MI:SS.# format.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setDate(int parameterIndex, java.sql.Date x)			throws SQLException {		saveObject(parameterIndex, x);		ps.setDate(parameterIndex, x);	}	/**	 * this implementation assumes that the Date has the date, and the calendar	 * has the local info. For the debug string, the cal date is set to the date	 * of x. Debug string displays date in YYYY-MM-DD HH24:MI:SS.# format.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 * @param cal	 *            uses x to set time	 */	public void setDate(int parameterIndex, java.sql.Date x, Calendar cal)			throws SQLException {		cal.setTime(new java.util.Date(x.getTime()));		saveObject(parameterIndex, cal);		ps.setDate(parameterIndex, x, cal);	}	/**	 * Adds double to debug string in parameterIndex position.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setDouble(int parameterIndex, double x) throws SQLException {		saveObject(parameterIndex, new Double(x));		ps.setDouble(parameterIndex, x);	}	/**	 * Facade for PreparedStatement	 */	public void setEscapeProcessing(boolean enable) throws SQLException {		ps.setEscapeProcessing(enable);	}	/**	 * Facade for PreparedStatement	 */	public void setFormatter(SqlFormatter formatter) {		this.formatter = formatter;	}	/**	 * Facade for PreparedStatement	 */	public void setFetchDirection(int direction) throws SQLException {		ps.setFetchDirection(direction);	}	/**	 * Facade for PreparedStatement	 */	public void setFetchSize(int rows) throws SQLException {		ps.setFetchSize(rows);	}	/**	 * Adds float to debug string in parameterIndex position.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setFloat(int parameterIndex, float x) throws SQLException {		saveObject(parameterIndex, new Float(x));		ps.setFloat(parameterIndex, x);	}	/**	 * Adds int to debug string in parameterIndex position.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setInt(int parameterIndex, int x) throws SQLException {		saveObject(parameterIndex, new Integer(x));		ps.setInt(parameterIndex, x);	}	/**	 * Adds long to debug string in parameterIndex position.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setLong(int parameterIndex, long x) throws SQLException {		saveObject(parameterIndex, new Long(x));		ps.setLong(parameterIndex, x);	}	/**	 * Facade for PreparedStatement	 */	public void setMaxFieldSize(int max) throws SQLException {		ps.setMaxFieldSize(max);	}	/**	 * Facade for PreparedStatement	 */	public void setMaxRows(int max) throws SQLException {		ps.setMaxRows(max);	}	/**	 * Adds a NULL to the debug String.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setNull(int parameterIndex, int sqlType) throws SQLException {		saveObject(parameterIndex, "NULL");		ps.setNull(parameterIndex, sqlType);	}	/**	 * Adds a NULL to the debug String.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 * @param typeName	 *            type of Object	 */	public void setNull(int parameterIndex, int sqlType, String typeName)			throws SQLException {		saveObject(parameterIndex, "NULL");		ps.setNull(parameterIndex, sqlType, typeName);	}	/**	 * Adds name of the object's class type to the debug String. If object is	 * null, NULL is added to debug String.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setObject(int parameterIndex, Object x) throws SQLException {		saveObject(parameterIndex,				(x == null ? "NULL" : x.getClass().getName()));		ps.setObject(parameterIndex, x);	}	/**	 * Adds name of the object's class type to the debug String. If object is	 * null, NULL is added to debug String.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 * @param targetSqlType	 *            database type	 */	public void setObject(int parameterIndex, Object x, int targetSqlType)			throws SQLException {		saveObject(parameterIndex,				(x == null ? "NULL" : x.getClass().getName()));		ps.setObject(parameterIndex, x, targetSqlType);	}	/**	 * Adds name of the object's class type to the debug String. If object is	 * null, NULL is added to debug String.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 * @param targetSqlType	 *            database type	 * @param scale	 *            see PreparedStatement	 */	public void setObject(int parameterIndex, Object x, int targetSqlType,			int scale) throws SQLException {		saveObject(parameterIndex,				(x == null ? "NULL" : x.getClass().getName()));		ps.setObject(parameterIndex, x, targetSqlType, scale);	}	/**	 * Facade for PreparedStatement	 */	public void setQueryTimeout(int seconds) throws SQLException {		ps.setQueryTimeout(seconds);	}	/**	 * From the javadocs: A reference to an SQL structured type value in the	 * database. A Ref can be saved to persistent storage. The output from this	 * method call in DebuggableStatement is a string representation of the Ref	 * object by calling the Ref object's getBaseTypeName() method. Again, this	 * will only be a String representation of the actual object being stored in	 * the database.	 * 	 * @param i	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setRef(int i, Ref x) throws SQLException {		saveObject(i, x);		ps.setRef(i, x);	}	/**	 * Adds short to debug string in parameterIndex position.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setShort(int parameterIndex, short x) throws SQLException {		saveObject(parameterIndex, new Short(x));		ps.setShort(parameterIndex, x);	}	/**	 * Adds String to debug string in parameterIndex position. If String is null	 * "NULL" is inserted in debug string. ***note**** In situations where a	 * single ' is in the string being inserted in the database. The debug	 * string will need to be modified to reflect this when running the debug	 * statement in the database.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setString(int parameterIndex, String x) throws SQLException {		saveObject(parameterIndex, x);		ps.setString(parameterIndex, x);	}	/**	 * Debug string displays Time in HH24:MI:SS.# format.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setTime(int parameterIndex, Time x) throws SQLException {		saveObject(parameterIndex, x);		ps.setTime(parameterIndex, x);	}	/**	 * This implementation assumes that the Time object has the time and	 * Calendar has the locale info. For the debug string, the cal time is set	 * to the value of x. Debug string displays time in HH24:MI:SS.# format.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 * @param cal	 *            sets time based on x	 */	public void setTime(int parameterIndex, Time x, Calendar cal)			throws SQLException {		cal.setTime(new java.util.Date(x.getTime()));		saveObject(parameterIndex, cal);		ps.setTime(parameterIndex, x, cal);	}	/**	 * Debug string displays timestamp in YYYY-MM-DD HH24:MI:SS.# format.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 */	public void setTimestamp(int parameterIndex, Timestamp x)			throws SQLException {		saveObject(parameterIndex, x);		ps.setTimestamp(parameterIndex, x);	}	/**	 * This implementation assumes that the Timestamp has the date/time and	 * Calendar has the locale info. For the debug string, the cal date/time is	 * set to the default value of Timestamp which is YYYY-MM-DD HH24:MI:SS.#.	 * Debug string displays timestamp in DateFormat.LONG format.	 * 	 * @param parameterIndex	 *            index of parameter	 * @param x	 *            parameter Object	 * @param cal	 *            sets time based on x	 */	public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)			throws SQLException {		cal.setTime(new java.util.Date(x.getTime()));		saveObject(parameterIndex, cal);		ps.setTimestamp(parameterIndex, x, cal);	}	/**	 * Method has been deprecated in PreparedStatement interface. This method is	 * present only to satisfy interface and does not do anything. Do not use...	 * 	 * @deprecated	 */	public void setUnicodeStream(int parameterIndex, InputStream x, int length)			throws SQLException {		// ps.setUnicodeStream(parameterIndex, x, length);	}	/**	 * this toString is overidden to return a String representation of the sql	 * statement being sent to the database. If a bind variable is missing then	 * the String contains a ? + (missing variable #)	 * 	 * @return the above string representation	 */	public String toString() {		StringTokenizer st = new StringTokenizer(filteredSql, "?");		int count = 1;		StringBuffer statement = new StringBuffer();		while (st.hasMoreTokens()) {			statement.append(st.nextToken());			if (count <= variables.length) {				if (variables[count - 1] != null						&& variables[count - 1].isValueAssigned()) {					try {						statement.append(formatter.format(variables[count - 1]								.getDebugObject()));					} catch (SQLException e) {						statement.append("SQLException");					}				} else {					statement.append("? " + "(missing variable # " + count							+ " ) ");				}			}			count++;		}		// unfilter the string in case there where rogue '?' in query string.		char[] unfilterSql = statement.toString().toCharArray();		for (int i = 0; i < unfilterSql.length; i++) {			if (unfilterSql[i] == '\u0007')				unfilterSql[i] = '?';		}		// return execute time		if (debugLevel == DebugLevel.ON)			return new String(unfilterSql);		else			return new String(unfilterSql)					+ System.getProperty("line.separator")					+ System.getProperty("line.separator")					+ "query executed in " + executeTime + " milliseconds"					+ System.getProperty("line.separator");	}	private Object executeVerboseQuery(String methodName, Class[] parameters)			throws SQLException, NoSuchMethodException,			InvocationTargetException, IllegalAccessException {		// determine which method we have		Method m = ps.getClass().getDeclaredMethod(methodName, parameters);		// debug is set to on, so no times are calculated		if (debugLevel == DebugLevel.ON)			return m.invoke(ps, parameters);		// calculate execution time for verbose debugging		start();		Object returnObject = m.invoke(ps, parameters);		end();		// return the executions return type		return returnObject;	}	private void start() {		startTime = System.currentTimeMillis();	}	private void end() {		executeTime = System.currentTimeMillis() - startTime;	}	private class DebugObject {		private Object debugObject;		private boolean valueAssigned;		public DebugObject(Object debugObject) {			this.debugObject = debugObject;			valueAssigned = true;		}		public Object getDebugObject() {			return debugObject;		}		public boolean isValueAssigned() {			return valueAssigned;		}	}	public void setURL(int arg0, URL arg1) throws SQLException {		// TODO Auto-generated method stub	}	public ParameterMetaData getParameterMetaData() throws SQLException {		// TODO Auto-generated method stub		return null;	}	public boolean getMoreResults(int arg0) throws SQLException {		// TODO Auto-generated method stub		return false;	}	public ResultSet getGeneratedKeys() throws SQLException {		// TODO Auto-generated method stub		return null;	}	public int executeUpdate(String arg0, int arg1) throws SQLException {		// TODO Auto-generated method stub		return 0;	}	public int executeUpdate(String arg0, int[] arg1) throws SQLException {		// TODO Auto-generated method stub		return 0;	}	public int executeUpdate(String arg0, String[] arg1) throws SQLException {		// TODO Auto-generated method stub		return 0;	}	public boolean execute(String arg0, int arg1) throws SQLException {		// TODO Auto-generated method stub		return false;	}	public boolean execute(String arg0, int[] arg1) throws SQLException {		// TODO Auto-generated method stub		return false;	}	public boolean execute(String arg0, String[] arg1) throws SQLException {		// TODO Auto-generated method stub		return false;	}	public int getResultSetHoldability() throws SQLException {		// TODO Auto-generated method stub		return 0;	}}

⌨️ 快捷键说明

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