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

📄 idaoimpl.java

📁 上网计费系统,适用网吧或者自己学习用用JAVA写成
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		}
	}

	public List getRadacctByCondition(String businessName, Date startDate,
			Date endDate, Integer offset, Integer maxNumPerPage)
			throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_RADACCT_BY_CONDITION);
		query.setString(0, businessName);
		query.setDate(1, startDate);
		query.setDate(2, endDate);
		query.setFirstResult(offset);
		query.setMaxResults(maxNumPerPage);
		List radaccts = query.list();
		return radaccts;
	}

	public Radcheck getRadcheckByName(String name) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_RADCHECK_BY_NAME);
		query.setString(0, name);
		List list = query.list();
		Radcheck radcheck = null;
		if (list.size() > 0) {
			radcheck = (Radcheck) list.get(0);
		}
		return radcheck;
	}

	public Radcheck getRadcheckById(Long id) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Radcheck radcheck = (Radcheck) session.get(Radcheck.class, id);
		return radcheck;
	}

	public List getRadreplyByUserName(String userName) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_RADREPLY_BY_USERNAME);
		query.setString(0, userName);
		List radreplies = query.list();
		return radreplies;
	}

	public void deleteRadreplyByName(Radreply radreply) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		session.delete(radreply);
	}

	public void deleteRadcheck(Radcheck radcheck) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		session.delete(radcheck);
	}

	public void updateRadcheck(Radcheck radcheck) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		session.update(radcheck);
	}

	public List getAllRoles() throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_ALL_ROLES);
		List roles = query.list();
		return roles;
	}

	public Role getRoleById(Long id) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Role role = (Role) session.get(Role.class, id);
		return role;
	}

	public void saveOrUpdateRole(Role role) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		session.saveOrUpdate(role);
		session.flush();
	}

	public void deleteRole(Long id) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Role role = (Role) session.get(Role.class, id);
		session.delete(role);
	}

	public List getAllProducts() throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_ALL_PRODUCTS);
		List list = query.list();
		return list;
	}

	public Product getProductById(Long productId) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_PRODUCT_BY_ID);
		query.setLong(0, productId);
		Product product = null;
		Iterator it = query.iterate();
		if (it.hasNext()) {
			product = (Product) it.next();
		}
		return product;
	}

	public void deleteProduct(Long id) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Product product = (Product) session.get(Product.class, id);
		session.delete(product);
	}

	public void saveOrUpdateProduct(Product product) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		session.saveOrUpdate(product);
	}

	public List getProductByNum(int offset, int maxNumPerPage) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_PRODUCT_BY_NUM);
		query.setFirstResult(offset);
		query.setMaxResults(maxNumPerPage);
		List products = query.list();
		return products;
	}

	public Integer getProductCount() throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_PRODUCT_COUNT);
		Integer count = null;
		List list = query.list();
		if (list.size() > 0) {
			count = (Integer) list.get(0);
		}
		return count;
	}

	public List getAllProductTypes() throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_ALL_PRODUCTTYPES);
		List list = query.list();
		return list;
	}

	public Long getHighValue() {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_HIGH_VALUE);
		Iterator it = query.iterate();
		Hv hv = null;
		Long high_value = 0L;
		if (it.hasNext()) {
			hv = (Hv) it.next();
			high_value = hv.getHighvalue();
			hv.setHighvalue(high_value + 1);
			session.saveOrUpdate(hv);
			session.flush();
		} else {
			hv = new Hv();
			hv.setHighvalue(20000000L);
			high_value = 20000000L;
			session.save(hv);
			session.flush();
		}

		return high_value;
	}

	public List getBusinessMonth() throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_BUSINESS_MONTH);
		int month = Calendar.getInstance().get(Calendar.MONTH);
		query.setInteger(0, month + 1);
		List list = query.list();
		return list;
	}

	public List getBusinessYear() throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_BUSINESS_YEAR);
		int year = Calendar.getInstance().get(Calendar.YEAR);
		query.setInteger(0, year);
		List list = query.list();
		return list;
	}

	public List getNasDay(String date) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_NAS_DAY);
		query.setString(0, date);
		List list = query.list();
		/*
		 * System.out.println("sql:" + GET_NAS_DAY); System.out.println("date:" +
		 * date); System.out.println("list.size():" + list.size());
		 */
		return list;
	}

	public List getNasMonth(String date) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_NAS_MONTH);
		query.setString(0, date);
		List list = query.list();
		/*
		 * System.out.println("sql:" + GET_NAS_MONTH);
		 * System.out.println("date:" + date); System.out.println("list.size():" +
		 * list.size());
		 */
		return list;
	}

	public List getNasYear(String date) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_NAS_YEAR);
		query.setString(0, date);
		List list = query.list();
		/*
		 * System.out.println("sql:" + GET_NAS_YEAR); System.out.println("date:" +
		 * date); System.out.println("list.size():" + list.size());
		 */
		return list;
	}

	public List getUserDay(String name, String year, String month, String day)
			throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_USER_DAY);
		query.setString(0, name);
		query.setString(1, year.trim() + month.trim() + day.trim());
		List userdays = query.list();
		return userdays;
	}

	public List getUserMonth(String name, String year, String month)
			throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_USER_MONTH);
		query.setString(0, name);
		query.setString(1, year.trim() + month.trim());
		List usermonths = query.list();
		/*
		 * Iterator iter = usermonths.iterator(); while (iter.hasNext()) {
		 * Usermonth user = (Usermonth) iter.next();
		 * System.out.println("&&&&&&&&1:" + year.trim() + month.trim());
		 * System.out.println("&&&&&&&&2:" + user.getTimeDuration());
		 * System.out.println("&&&&&&&&3:" + user.getFlux());
		 * System.out.println("&&&&&&&&4:" + user.getOndate()); }
		 */
		return usermonths;
	}

	public List getUserYear(String name, String year) throws Exception {
		Session session = HibernateSessionFactory.getSession();
		Query query = session.createQuery(GET_USER_YEAR);
		query.setString(0, name);
		query.setString(1, year.trim());
		List useryears = query.list();
		return useryears;
	}

	public static void main(String[] args) throws Exception {
		String driver = "oracle.jdbc.driver.OracleDriver";
		String url = "jdbc:oracle:thin:@192.168.1.220:1521:briupdb";
		String user = "woss";
		String password = "woss";
		Class.forName(driver);
		Connection con = DriverManager.getConnection(url, user, password);
		String sql = "select * from productstype where rownum=1";
		PreparedStatement pstm = con
				.prepareStatement(sql);
		/*pstm.setInt(1, 2);
		pstm.setString(2, "按月租收费");
		pstm.setString(3, "按月租收费");
		pstm.execute();*/
		
		ResultSet rs = pstm.executeQuery(sql);
		while (rs.next()) {
			String name = rs.getString("name");
			System.out.println("name:" + name);
		}

		/*
		 * ProductType pt1 = new ProductType(); pt1.setId(1L);
		 * pt1.setName("按月租收费"); pt1.setRemark("按月租收费");
		 * session.saveOrUpdate(pt1);
		 * 
		 * ProductType pt2 = new ProductType(); pt2.setId(2L);
		 * pt2.setName("按小时收费"); pt2.setRemark("按小时收费");
		 * session.saveOrUpdate(pt2);
		 * 
		 * ProductType pt3 = new ProductType(); pt3.setId(3L);
		 * pt3.setName("按流量收费"); pt3.setRemark("按流量收费");
		 * session.saveOrUpdate(pt3);
		 * 
		 * ProductType pt4 = new ProductType(); pt4.setId(4L);
		 * pt4.setName("按月租和小时收费"); pt4.setRemark("按月租和小时收费");
		 * session.saveOrUpdate(pt4); tran.commit();
		 */
		System.out.println("success!");
	}

}

⌨️ 快捷键说明

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