Created
October 22, 2011 00:41
-
-
Save nitindhar7/1305364 to your computer and use it in GitHub Desktop.
ResultSet Design Pattern: retrieving records
This file contains hidden or 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
| public class UsersResultSet { | |
| private ResultSet _rs; | |
| private PreparedStatement _ps; | |
| private Connection _conn; | |
| public UsersResultSet(ResultSet rs, PreparedStatement ps, Connection conn) { | |
| _rs = rs; | |
| _ps = ps; | |
| _conn = conn; | |
| } | |
| public Order getNextUser() { | |
| User user = null; | |
| try { | |
| if (_rs.next()) { | |
| user = new User(); | |
| // ... build user from rs row ... | |
| } | |
| } catch (SQLException se) { | |
| // Deal with exception | |
| } | |
| return user; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment