File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
dao/src/main/java/com/iluwatar/dao Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ public Stream<Customer> getAll() throws Exception {
65
65
Connection connection ;
66
66
try {
67
67
connection = getConnection ();
68
- PreparedStatement statement = connection .prepareStatement ("SELECT * FROM CUSTOMERS" );
69
- ResultSet resultSet = statement .executeQuery ();
68
+ PreparedStatement statement = connection .prepareStatement ("SELECT * FROM CUSTOMERS" ); //NOSONAR
69
+ ResultSet resultSet = statement .executeQuery (); //NOSONAR
70
70
return StreamSupport .stream (new Spliterators .AbstractSpliterator <Customer >(Long .MAX_VALUE ,
71
71
Spliterator .ORDERED ) {
72
72
@@ -82,7 +82,7 @@ public boolean tryAdvance(Consumer<? super Customer> action) {
82
82
throw new RuntimeException (e );
83
83
}
84
84
}
85
- }, false ).onClose (() -> mutedClose (connection ));
85
+ }, false ).onClose (() -> mutedClose (connection , statement , resultSet ));
86
86
} catch (SQLException e ) {
87
87
throw new Exception (e .getMessage (), e );
88
88
}
@@ -92,8 +92,10 @@ private Connection getConnection() throws SQLException {
92
92
return dataSource .getConnection ();
93
93
}
94
94
95
- private void mutedClose (Connection connection ) {
95
+ private void mutedClose (Connection connection , PreparedStatement statement , ResultSet resultSet ) {
96
96
try {
97
+ resultSet .close ();
98
+ statement .close ();
97
99
connection .close ();
98
100
} catch (SQLException e ) {
99
101
e .printStackTrace ();
You can’t perform that action at this time.
0 commit comments