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

📄 usersdaosample.java

📁 这是Java学习的一些常用的例子
💻 JAVA
字号:
/*
 * 
 * 开发时间:2004-08-20 at 05:40:07
 *
 * 作者:曹广鑫
 *
 * 网站:www.helpsoft.org  电子邮件:support@helpsoft.org
 */

package org.helpsoft.blog.example;

import java.math.*;
import java.util.Date;
import java.util.Collection;
import org.helpsoft.blog.dao.UsersDao;
import org.helpsoft.blog.dto.Users;
import org.helpsoft.blog.exceptions.UsersDaoException;
import org.helpsoft.blog.factory.UsersDaoFactory;

public class UsersDaoSample
{
	/**
	 * Method 'main'
	 *
	 * @param arg
	 * @throws Exception
	 */
	public static void main(String[] arg) throws Exception
	{
		// Uncomment one of the lines below to test the generated code

		 findAll();
		// findWhereUseridEquals("");
		// findWhereNameEquals("");
	}

	/**
	 * Method 'findAll'
	 *
	 */
	public static void findAll()
	{
		try {
			UsersDao _dao = getUsersDao();
			Users _result[] = _dao.findAll();
			for (int i=0; i<_result.length; i++ ) {
				display( _result[i] );
			}

		}
		catch (Exception _e) {
			_e.printStackTrace();
		}

	}

	/**
	 * Method 'findWhereUseridEquals'
	 *
	 * @param userid
	 */
	public static void findWhereUseridEquals(String userid)
	{
		try {
			UsersDao _dao = getUsersDao();
			Users _result[] = _dao.findWhereUseridEquals(userid);
			for (int i=0; i<_result.length; i++ ) {
				display( _result[i] );
			}

		}
		catch (Exception _e) {
			_e.printStackTrace();
		}

	}

	/**
	 * Method 'findWhereNameEquals'
	 *
	 * @param name
	 */
	public static void findWhereNameEquals(String name)
	{
		try {
			UsersDao _dao = getUsersDao();
			Users _result[] = _dao.findWhereNameEquals(name);
			for (int i=0; i<_result.length; i++ ) {
				display( _result[i] );
			}

		}
		catch (Exception _e) {
			_e.printStackTrace();
		}

	}

	/**
	 * Method 'getUsersDao'
	 *
	 * @return UsersDao
	 */
	public static UsersDao getUsersDao()
	{
		return UsersDaoFactory.create();
	}

	/**
	 * Method 'display'
	 *
	 * @param dto
	 */
	public static void display(Users dto)
	{
		StringBuffer buf = new StringBuffer();
		buf.append( dto.getUserid() );
		buf.append( ", " );
		buf.append( dto.getPassword() );
		buf.append( ", " );
		buf.append( dto.getName() );
		System.out.println( buf.toString() );
	}

}

⌨️ 快捷键说明

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