Skip to content

Instantly share code, notes, and snippets.

@wspeirs
Created January 8, 2014 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wspeirs/8325877 to your computer and use it in GitHub Desktop.
Save wspeirs/8325877 to your computer and use it in GitHub Desktop.
// Use a ResultSetHandler implementation, ArrayHandler, to convert the
// first row into an Object[].
ResultSetHandler<Object[]> handler = new ArrayHandler();
// Create a QueryRunner that will use connections from
// the given DataSource
QueryRunner runner = new QueryRunner(dataSource);
// Generate a QueryExecutor for the query
QueryExecutor executor = runner.query("SELECT * FROM Person WHERE first_name=:first_name and last_name = :last_name");
// Bind our parameters and execute the query
Object[] result = executor.bind("first_name", "John")
.bind("last_name", "Doe")
.execute(handler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment