-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ JDBC 2단계] 박스터 미션 제출합니다. #282
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4c39319
refactor: try with resource 로 변경
drunkenhw e320796
refactor: result set 중복 제거
drunkenhw f033beb
refactor: prepare statement 추상화
drunkenhw 903f8c1
refactor: optional을 반환하도록 변경
drunkenhw b776e9c
refactor: 가독성을 위해 구현체 추가
drunkenhw 68f9e4f
refactor: final 제거
drunkenhw 0b48a3f
refactor: final 제거
drunkenhw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.springframework.jdbc.core; | ||
|
||
import java.sql.PreparedStatement; | ||
import java.sql.SQLException; | ||
|
||
public interface PreparedStatementExecutor<T> { | ||
|
||
T fetchData(PreparedStatement statement) throws SQLException; | ||
} |
8 changes: 8 additions & 0 deletions
8
jdbc/src/main/java/org/springframework/jdbc/core/ResultSetExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.springframework.jdbc.core; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
public interface ResultSetExecutor<T> { | ||
T extractData(ResultSet resultSet) throws SQLException; | ||
} |
24 changes: 24 additions & 0 deletions
24
jdbc/src/main/java/org/springframework/jdbc/core/RowMapResultSetExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.springframework.jdbc.core; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class RowMapResultSetExecutor<T> implements ResultSetExecutor<List<T>> { | ||
|
||
private final RowMapper<T> rowMapper; | ||
|
||
public RowMapResultSetExecutor(RowMapper<T> rowMapper) { | ||
this.rowMapper = rowMapper; | ||
} | ||
|
||
@Override | ||
public List<T> extractData(ResultSet resultSet) throws SQLException { | ||
List<T> results = new ArrayList<>(); | ||
while (resultSet.next()) { | ||
results.add(rowMapper.mapRow(resultSet)); | ||
} | ||
return results; | ||
} | ||
Comment on lines
+16
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻👍🏻👍🏻👍🏻 |
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 방법이 있다더니.. 이제는 자바의 신이 되어버리셨네요 ㅋㅋㅋ