?? userdao.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);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -