查询操作 获取service层统一的connection对象,补充预编译sql语句,返回结果集 @param connection @param pstm @param resultSet @param sql @param params @return @throws Exception
(Connection connection, PreparedStatement pstm,ResultSet resultSet, String sql, Object[] params)
| 71 | * @throws Exception |
| 72 | */ |
| 73 | public static ResultSet execute(Connection connection, PreparedStatement pstm,ResultSet resultSet, String sql, Object[] params) throws Exception { |
| 74 | //预编译SQL语句,返回一个PreparedStatement实例 |
| 75 | pstm = connection.prepareStatement(sql); |
| 76 | for (int i = 0; i < params.length; i++) { |
| 77 | pstm.setObject(i+1,params[i]); |
| 78 | } |
| 79 | resultSet = pstm.executeQuery(); |
| 80 | return resultSet; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * 更新操作,返回受影响的行数 |
no outgoing calls
no test coverage detected