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

📄 persondao.java

📁 基于SPRING+DWR+EXT 技术的一个小项目(附源码和数据库脚本)
💻 JAVA
字号:
package com.hr.dao;

import java.util.ArrayList;
import java.util.List;

import com.hr.Person;
import com.philisense.arc.base.ProxyWebArcContext;
import com.philisense.arc.base.jdbc.query.Query;
import com.philisense.arc.base.jdbc.query.Runner;

public class PersonDAO {

	private Query query;

	private Runner getRunner() throws Exception {
		return (Runner) ProxyWebArcContext.getProxyArcContext().getQueryFactory().getRunnerObject();
	}

	private Query getQuery() throws Exception {
		if (query == null) {
			query = (Query) ProxyWebArcContext.getProxyArcContext().getQueryFactory().getObject();
		}
		return query;
	}

	public int removeRecords(ArrayList<String> ids) throws Exception {

		if (ids == null || ids.size() == 0) {
			return -1;
		}

		String sql = "delete from person where id in (";
		for (int i = 0; i < ids.size(); i++) {
			sql += ids.get(i).toString() + ",";
		}
		sql = sql.substring(0, sql.length() - 1) + ")";

		Runner runner = getRunner();
		int count = runner.executeUpdate(sql);
		runner.close();

		return count;
	}

	public List<Person> getRecords() throws Exception {

		Query query = getQuery();
		query.setNullWarp(true);
		query.setTrimWarp(true);
		query.setColumnWarp(false);
		query.setCodeWarp(false);

		return (List<Person>) query.queryToBeanList("select * from person order by id", Person.class);
	}

	public int insertPerson(String name, String age, String unitName, String address, String telephone, String gender)
			throws Exception {
		String sql = "insert into Person(name,age,unitName,address,telephone,gender) values('" + name + "','" + age
				+ "','" + unitName + "','" + address + "','" + telephone + "','" + gender + "')";

		Runner runner = getRunner();
		int count = runner.executeUpdate(sql);
		runner.close();

		return count;
	}

	public int updatePerson(String id, String name, String age, String unitName, String address, String telephone,
			String gender) throws Exception {

		String sql = "update Person set name='" + name + "',age='" + age + "',unitName='" + unitName + "',address='"
				+ address + "',telephone='" + telephone + "',gender='" + gender + "' where id=" + id;

		Runner runner = getRunner();
		int count = runner.executeUpdate(sql);
		runner.close();

		return count;
	}
}

⌨️ 快捷键说明

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