Skip to content

Instantly share code, notes, and snippets.

@ps06756
Last active August 20, 2017 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ps06756/a5860717feff7f60d14fbff515d33923 to your computer and use it in GitHub Desktop.
Save ps06756/a5860717feff7f60d14fbff515d33923 to your computer and use it in GitHub Desktop.
try ( Connection connection = dataSource.getConnection(); ){
try( PreparedStatement pstmt = connection.prepareStatement("SELECT studentName from student where studentId = 1"); ) {
try( ResultSet resultSet = pstmt.executeQuery(); ) {
while (resultSet.next()) {
System.out.println(resultSet.getString(1));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment