一、前言
最近公司项目准备开始重构,框架选定为 Spring Boot ,本篇主要记录了在 IDEA 中搭建 Spring Boot Maven 多模块项目的过程。
这篇文章可以说是完全的一篇实战项目干货,感兴趣的朋友们可以继续看下去
rs = ps.executeQuery();
//创建List集合
List<Map<String, Object>> list = new ArrayList<>();
//获取本次查询结果集有多少列
int count = rs.getMetaData().getColumnCount();
//while循环
while(rs.next()){
//创建Map集合 获取一个数据封装成一个Map集合
Map<String, Object> map = new HashMap<>();
//for循环 遍历所有的列
for(int i=0;i<count;i++){
//获取本次查询结果集的列名
String name = rs.getMetaData().getColumnLabel(i + 1);
map.put(name,rs.getObject(name));
}
//把所有的map集合添加到List集合中
list.add(map);
}
//返回值
return list;
} catch (SQLException e) {
e.printStackTrace();
}finally{
//关闭资源
close(conn,ps,rs);
}
return null;
}
/**
-
关闭资源的通用方法
-
*/
public static void close(Connection conn,Statement stat,ResultSet rs){
try{
if(rs!=null){
rs.close();
}
if(stat!=null){
stat.close();
}
if(conn!=null){
conn.close();
}
}catch(Exception e){
e.printStackTrace();
}
}
}
自定义配置文件版
public class BaseDao {
// 配置集合
public static Properties properties = new Properties();
// 加载驱动
static { <