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

📄 userdao.java

📁 本demo为完整的
💻 JAVA
字号:
package com.greysh.genix.dao;

import java.io.IOException;
import java.io.Reader;
import java.sql.SQLException;
import java.util.List;
import com.greysh.genix.model.User;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class UserDao {
	private static SqlMapClient sqlMapper;
	static {
		try {
			String source = "com\\greysh\\genix\\config\\SqlMapConfig.xml";
			Reader reader = Resources.getResourceAsReader(source);
			sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
			reader.close();
		} catch (IOException e) {
			throw new RuntimeException(
					"Something bad happened while building the SqlMapClient instance."
							+ e, e);
		}
	}

	public static List<?> selectAllUser() throws SQLException {
		return sqlMapper.queryForList("selectAllUser");
	}

	public static User selectUserById(int id) throws SQLException {
		return (User) sqlMapper.queryForObject("selectUserById", id);
	}

	public static void insertUser(User user) throws SQLException {
		sqlMapper.insert("insertUser", user);
	}

	public static void updateUser(User user) throws SQLException {
		sqlMapper.update("updateUser", user);
	}

	public static void deleteUser(int id) throws SQLException {
		sqlMapper.delete("deleteUserById", id);
	}

}

⌨️ 快捷键说明

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