91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3.1MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-10-28
  • 語言: Java
  • 標簽: JSP??

資源簡介

基于JSP的學生管理系統 基于JSP的學生管理系統 基于JSP的學生管理系統

資源截圖

代碼片段和文件信息

package?com.fuzhu.studentmanager;

import?java.lang.reflect.InvocationTargetException;
import?java.sql.Connection;
import?java.sql.PreparedStatement;
import?java.sql.ResultSet;
import?java.sql.ResultSetmetaData;
import?java.sql.SQLException;
import?java.util.ArrayList;
import?java.util.HashMap;
import?java.util.List;
import?java.util.Map;

import?org.apache.commons.beanutils.BeanUtils;
import?org.slf4j.Logger;
import?org.slf4j.LoggerFactory;

import?com.user.Slf4jTest;

public?class?DAO?{
??private?static?Logger?Log?=?LoggerFactory.getLogger(Slf4jTest.class);

//?INSERT?UPDATE?DELETE操作都可以包含在其中
public?void?update(String?sql?object...?args)?{
Connection?connection?=?null;
PreparedStatement?preparedStatement?=?null;
try?{
connection?=?JDBCTools.getConnection();
preparedStatement?=?connection.prepareStatement(sql);
for?(int?i?=?0;?i? preparedStatement.setobject(i?+?1?args[i]);
}
preparedStatement.executeUpdate();
}?catch?(Exception?e)?{
e.printStackTrace();
}?finally?{
JDBCTools.release(null?preparedStatement?connection);
}
}

public??T?get(Class?clazz?String?sql?object...?args)?{
List?result?=?getForList(clazz?sql?args);
if?(result.size()?>?0)?{
return?result.get(0);
}
return?null;
}

//?查詢多條記錄,返回對應的對象的集合
public??List?getForList(Class?clazz?String?sql?object...?args)?{
List?list?=?new?ArrayList<>();

Connection?connection?=?null;
PreparedStatement?preparedStatement?=?null;
ResultSet?resultSet?=?null;
try?{
//?總步驟.(1)?得到結果集
connection?=?JDBCTools.getConnection();
preparedStatement?=?connection.prepareStatement(sql);
for?(int?i?=?0;?i? preparedStatement.setobject(i?+?1?args[i]);
}
resultSet?=?preparedStatement.executeQuery();
//?總步驟(2)處理結果集,得到Map的List,其中一個Map對象就是一條記錄。Map的key為resultSet中列的別名,Map的value為列的值
//?5-11方法隔離抽取:處理結果集,得到Map的一個List,其中一個Map對象對應一條記錄
Listject>>?values?=?handleResultSetToMapList(resultSet);

//?總步驟(3)把Map的List轉為clazz對應的List集合,其中Map的key即為clazz對應的對象的propertyName,而Map的value即為clazz對應的對象的propertyValue
//?12.
//?判斷List是否為空,不為空則遍歷List,得到一個一個的Map,再把一個Map對象轉為一個對應的Class參數對應的object對象。
list?=?transferMapListToBeanList(clazz?values);

}?catch?(Exception?e)?{
//?TODO:?handle?exception
e.printStackTrace();
}?finally?{
JDBCTools.release(resultSet?preparedStatement?connection);
}
return?list;
}
/**
?*?處理結果集,得到Map的一個List,其中一個Map對象對應一條記錄
?*?
?*?@param?resultSet
?*?@return
?*?@throws?SQLException
?*/
private?Listject>>?handleResultSetToMapList(ResultSet?resultSet)?throws?SQLException?{
//?5.
//?若ResultSet中有記錄--準備一個Listject>>:鍵:存放列的別名;值:存放列的值。其中一個Map對象對應一條記錄。
Listject>>?values?=?new?ArrayList<>();

//?ResultSetmetaData?rsmd?=resultSet.getmetaData();?//優化這個方法
List?columnLabels?=?getColumnLabels(resultSet);
Ma

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-04-08?17:52??StudentManagement\
?????文件????????1351??2018-04-09?15:23??StudentManagement\.classpath
?????文件????????6148??2018-04-09?18:44??StudentManagement\.DS_Store
?????目錄???????????0??2018-06-26?14:59??__MACOSX\
?????目錄???????????0??2018-06-26?14:59??__MACOSX\StudentManagement\
?????文件?????????120??2018-04-09?18:44??__MACOSX\StudentManagement\._.DS_Store
?????目錄???????????0??2018-04-09?20:46??StudentManagement\.git\
?????文件?????????317??2018-04-08?17:45??StudentManagement\.git\config
?????文件??????????73??2018-04-08?17:45??StudentManagement\.git\description
?????文件??????????23??2018-04-08?17:45??StudentManagement\.git\HEAD
?????目錄???????????0??2018-04-08?17:45??StudentManagement\.git\hooks\
?????文件?????????478??2018-04-08?17:45??StudentManagement\.git\hooks\applypatch-msg.sample
?????文件?????????896??2018-04-08?17:45??StudentManagement\.git\hooks\commit-msg.sample
?????文件?????????189??2018-04-08?17:45??StudentManagement\.git\hooks\post-update.sample
?????文件?????????424??2018-04-08?17:45??StudentManagement\.git\hooks\pre-applypatch.sample
?????文件????????1642??2018-04-08?17:45??StudentManagement\.git\hooks\pre-commit.sample
?????文件????????1348??2018-04-08?17:45??StudentManagement\.git\hooks\pre-push.sample
?????文件????????4951??2018-04-08?17:45??StudentManagement\.git\hooks\pre-rebase.sample
?????文件????????1239??2018-04-08?17:45??StudentManagement\.git\hooks\prepare-commit-msg.sample
?????文件????????3610??2018-04-08?17:45??StudentManagement\.git\hooks\update.sample
?????文件????????7780??2018-04-09?16:03??StudentManagement\.git\index
?????目錄???????????0??2018-04-08?17:45??StudentManagement\.git\info\
?????文件?????????240??2018-04-08?17:45??StudentManagement\.git\info\exclude
?????目錄???????????0??2018-04-08?17:45??StudentManagement\.git\logs\
?????文件?????????190??2018-04-08?17:45??StudentManagement\.git\logs\HEAD
?????目錄???????????0??2018-04-08?17:45??StudentManagement\.git\logs\refs\
?????目錄???????????0??2018-04-08?17:45??StudentManagement\.git\logs\refs\heads\
?????文件?????????190??2018-04-08?17:45??StudentManagement\.git\logs\refs\heads\master
?????目錄???????????0??2018-04-08?17:45??StudentManagement\.git\logs\refs\remotes\
?????目錄???????????0??2018-04-08?17:45??StudentManagement\.git\logs\refs\remotes\origin\
?????文件?????????190??2018-04-08?17:45??StudentManagement\.git\logs\refs\remotes\origin\HEAD
............此處省略293個文件信息

評論

共有 條評論