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

📄 htdaoimpl.java

📁 Struts+jdbc开发的合同管理系统,用的SQL Server 2000做为后台数据库!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:

	/** 
	 * Returns all rows from the ht table that match the criteria 'htbm = :htbm'.
	 */
	public Ht findByPrimaryKey(String htbm) throws HtDaoException
	{
		Ht ret[] = findByDynamicSelect( SQL_SELECT + " WHERE htbm = ?", new Object[] { htbm } );
		return ret.length==0 ? null : ret[0];
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'htbm = :htbm'.
	 */
	public Ht[] findWhereHtbmEquals(String htbm) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE htbm = ? ORDER BY htbm", new Object[] { htbm } );
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'jfdlrbm = :jfdlrbm'.
	 */
	public Ht[] findWhereJfdlrbmEquals(String jfdlrbm) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE jfdlrbm = ? ORDER BY jfdlrbm", new Object[] { jfdlrbm } );
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'jfbm = :jfbm'.
	 */
	public Ht[] findWhereJfbmEquals(String jfbm) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE jfbm = ? ORDER BY jfbm", new Object[] { jfbm } );
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'qsdd = :qsdd'.
	 */
	public Ht[] findWhereQsddEquals(String qsdd) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE qsdd = ? ORDER BY qsdd", new Object[] { qsdd } );
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'yf = :yf'.
	 */
	public Ht[] findWhereYfEquals(String yf) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE yf = ? ORDER BY yf", new Object[] { yf } );
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'yfdlr = :yfdlr'.
	 */
	public Ht[] findWhereYfdlrEquals(String yfdlr) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE yfdlr = ? ORDER BY yfdlr", new Object[] { yfdlr } );
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'jfqzrq = :jfqzrq'.
	 */
	public Ht[] findWhereJfqzrqEquals(Date jfqzrq) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE jfqzrq = ? ORDER BY jfqzrq", new Object[] { jfqzrq==null ? null : new java.sql.Timestamp( jfqzrq.getTime() ) } );
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'yfqzrq = :yfqzrq'.
	 */
	public Ht[] findWhereYfqzrqEquals(Date yfqzrq) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE yfqzrq = ? ORDER BY yfqzrq", new Object[] { yfqzrq==null ? null : new java.sql.Timestamp( yfqzrq.getTime() ) } );
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'xmmc = :xmmc'.
	 */
	public Ht[] findWhereXmmcEquals(String xmmc) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE xmmc = ? ORDER BY xmmc", new Object[] { xmmc } );
	}

	/** 
	 * Returns all rows from the ht table that match the criteria 'htnr = :htnr'.
	 */
	public Ht[] findWhereHtnrEquals(String htnr) throws HtDaoException
	{
		return findByDynamicSelect( SQL_SELECT + " WHERE htnr = ? ORDER BY htnr", new Object[] { htnr } );
	}

	/**
	 * Method 'HtDaoImpl'
	 * 
	 */
	public HtDaoImpl()
	{
	}

	/**
	 * Method 'HtDaoImpl'
	 * 
	 * @param userConn
	 */
	public HtDaoImpl(final java.sql.Connection userConn)
	{
		this.userConn = userConn;
	}

	/** 
	 * Sets the value of maxRows
	 */
	public void setMaxRows(int maxRows)
	{
		this.maxRows = maxRows;
	}

	/** 
	 * Gets the value of maxRows
	 */
	public int getMaxRows()
	{
		return maxRows;
	}

	/**
	 * Method 'getTableName'
	 * 
	 * @return String
	 */
	public String getTableName()
	{
		return "ht";
	}

	/** 
	 * Fetches a single row from the result set
	 */
	protected Ht fetchSingleResult(ResultSet rs) throws SQLException
	{
		if (rs.next()) {
			Ht dto = new Ht();
			populateDto( dto, rs);
			return dto;
		} else {
			return null;
		}
		
	}

	/** 
	 * Fetches multiple rows from the result set
	 */
	protected Ht[] fetchMultiResults(ResultSet rs) throws SQLException
	{
		Collection resultList = new ArrayList();
		while (rs.next()) {
			Ht dto = new Ht();
			populateDto( dto, rs);
			resultList.add( dto );
		}
		
		Ht ret[] = new Ht[ resultList.size() ];
		resultList.toArray( ret );
		return ret;
	}

	/** 
	 * Populates a DTO with data from a ResultSet
	 */
	protected void populateDto(Ht dto, ResultSet rs) throws SQLException
	{
		dto.setHtbm( rs.getString( COLUMN_HTBM ) );
		dto.setJfdlrbm( rs.getString( COLUMN_JFDLRBM ) );
		dto.setJfbm( rs.getString( COLUMN_JFBM ) );
		dto.setQsdd( rs.getString( COLUMN_QSDD ) );
		dto.setYf( rs.getString( COLUMN_YF ) );
		dto.setYfdlr( rs.getString( COLUMN_YFDLR ) );
		dto.setJfqzrq( rs.getTimestamp(COLUMN_JFQZRQ ) );
		dto.setYfqzrq( rs.getTimestamp(COLUMN_YFQZRQ ) );
		dto.setXmmc( rs.getString( COLUMN_XMMC ) );
		dto.setHtnr( rs.getString( COLUMN_HTNR ) );
	}

	/** 
	 * Returns all rows from the ht table that match the specified arbitrary SQL statement
	 */
	public Ht[] findByDynamicSelect(String sql, Object[] sqlParams) throws HtDaoException
	{
		// declare variables
		final boolean isConnSupplied = (userConn != null);
		Connection conn = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		
		try {
			// get the user-specified connection or get a connection from the ResourceManager
			conn = isConnSupplied ? userConn : ResourceManager.getConnection();
		
			// construct the SQL statement
			final String SQL = sql;
		
		
			if (logger.isDebugEnabled()) {
				logger.debug( "Executing " + SQL);
			}
		
			// prepare statement
			stmt = conn.prepareStatement( SQL );
			stmt.setMaxRows( maxRows );
		
			// bind parameters
			for (int i=0; sqlParams!=null && i<sqlParams.length; i++ ) {
				stmt.setObject( i+1, sqlParams[i] );
			}
		
		
			rs = stmt.executeQuery();
		
			// fetch the results
			return fetchMultiResults(rs);
		}
		catch (SQLException _e) {
			logger.error( "SQLException: " + _e.getMessage(), _e );
			throw new HtDaoException( "SQLException: " + _e.getMessage(), _e );
		}
		catch (Exception _e) {
			logger.error( "Exception: " + _e.getMessage(), _e );
			throw new HtDaoException( "Exception: " + _e.getMessage(), _e );
		}
		finally {
			ResourceManager.close(rs);
			ResourceManager.close(stmt);
			if (!isConnSupplied) {
				ResourceManager.close(conn);
			}
		
		}
		
	}

	/** 
	 * Returns all rows from the ht table that match the specified arbitrary SQL statement
	 */
	public Ht[] findByDynamicWhere(String sql, Object[] sqlParams) throws HtDaoException
	{
		// declare variables
		final boolean isConnSupplied = (userConn != null);
		Connection conn = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		
		try {
			// get the user-specified connection or get a connection from the ResourceManager
			conn = isConnSupplied ? userConn : ResourceManager.getConnection();
		
			// construct the SQL statement
			final String SQL = SQL_SELECT + " WHERE " + sql;
		
		
			if (logger.isDebugEnabled()) {
				logger.debug( "Executing " + SQL);
			}
		
			// prepare statement
			stmt = conn.prepareStatement( SQL );
			stmt.setMaxRows( maxRows );
		
			// bind parameters
			for (int i=0; sqlParams!=null && i<sqlParams.length; i++ ) {
				stmt.setObject( i+1, sqlParams[i] );
			}
		
		
			rs = stmt.executeQuery();
		
			// fetch the results
			return fetchMultiResults(rs);
		}
		catch (SQLException _e) {
			logger.error( "SQLException: " + _e.getMessage(), _e );
			throw new HtDaoException( "SQLException: " + _e.getMessage(), _e );
		}
		catch (Exception _e) {
			logger.error( "Exception: " + _e.getMessage(), _e );
			throw new HtDaoException( "Exception: " + _e.getMessage(), _e );
		}
		finally {
			ResourceManager.close(rs);
			ResourceManager.close(stmt);
			if (!isConnSupplied) {
				ResourceManager.close(conn);
			}
		
		}
		
	}

}

⌨️ 快捷键说明

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