Created
October 22, 2011 00:35
-
-
Save nitindhar7/1305353 to your computer and use it in GitHub Desktop.
ResultSet Pattern
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
public class UsersJDBCDao { | |
private static final String GET_ALL_USERS = "SELECT * FROM users"; | |
public UsersResultSet getAllUsers() { | |
Connection conn = null; | |
PreparedStatement ps = null; | |
ResultSet rs = null; | |
try { | |
conn = getConnection(); | |
ps = conn.prepareStatement(GET_ALL_ORDERS); | |
ps.setFetchSize(1000); // Fetch users lazily 1000-by-1000 | |
rs = ps.executeQuery(); | |
return new UsersResultSet(rs, ps, conn); | |
} catch (SQLException se) { | |
// Deal with exception | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment