import java.util.List;

import com.github.fjdbc.ConnectionProvider;
import com.github.fjdbc.Fjdbc;
import com.github.fjdbc.PreparedStatementBinder;
import com.github.fjdbc.op.DbOperation;
import com.github.fjdbc.query.ResultSetExtractor;

public class Examples {
	public static void main(String[] args) {
		final ConnectionProvider cnxProvider = null;
		final Fjdbc fjdbc = new Fjdbc(cnxProvider);

		// -------------------------------------------------------------------------------------------------------------
		// Query the database
		{
			final String sql = "select name from user";
			final ResultSetExtractor<String> extractor = (rs) -> rs.getString("name");
			final List<String> names = fjdbc.query(sql, extractor).toList();
			System.out.println(names);
		}

		// -------------------------------------------------------------------------------------------------------------
		// Query the database using a prepared statement
		{
			final String sql = "select name from user where role = ?";
			final PreparedStatementBinder binder = (ps, seq) -> ps.setString(seq.next(), "grunt");
			final ResultSetExtractor<String> extractor = rs -> rs.getString("name");
			final List<String> names = fjdbc.query(sql, binder, extractor).toList();
			System.out.println(names);
		}

		// -------------------------------------------------------------------------------------------------------------
		// Execute a statement (update, delete, insert, etc)
		{
			final String sql = "update user set name='jack' where name='henri'";
			final int nRows = fjdbc.statement(sql).executeAndCommit(cnxProvider);
			System.out.println(nRows + " rows changed");
		}

		// -------------------------------------------------------------------------------------------------------------
		// Execute a prepared statement
		{
			final String sql = "update user set name=? where name=?";
			final PreparedStatementBinder binder = (ps, paramIndex) -> {
				ps.setString(paramIndex.next(), "jack");
				ps.setString(paramIndex.next(), "henri");
			};
			final int nRows = fjdbc.statement(sql, binder).executeAndCommit(cnxProvider);
			System.out.println(nRows + " rows changed");
		}

		// -------------------------------------------------------------------------------------------------------------
		// Execute a sequence of statements (in a single transaction)
		{
			final PreparedStatementBinder binder = (ps, paramIndex) -> {
				ps.setString(paramIndex.next(), "jack");
				ps.setString(paramIndex.next(), "henri");
			};
			final DbOperation updateName = fjdbc.statement("update user set name=? where name=?", binder);

			final PreparedStatementBinder binder2 = (ps, paramIndex) -> {
				ps.setString(paramIndex.next(), "manager");
			};
			final DbOperation deleteManagers = fjdbc.statement("delete from user where role=?", binder2);

			final int nRows = fjdbc.composite(updateName, deleteManagers).executeAndCommit(cnxProvider);
			System.out.println(nRows + " rows changed");
		}
	}
}

@@ -9,65 +9,112 @@
 ava.
-util.List;%0D%0A%0D%0Aimport com.github.fjdbc.ConnectionProvider;
+sql.Connection;%0D%0Aimport java.sql.DriverManager;%0D%0Aimport java.sql.SQLException;%0D%0Aimport java.util.List;%0D%0A
 %0D%0Aim
@@ -189,24 +189,75 @@
 entBinder;%0D%0A
+import com.github.fjdbc.SingleConnectionProvider;%0D%0A
 import com.g
@@ -402,16 +402,36 @@
 %5B%5D args)
+ throws SQLException
  %7B%0D%0A%09%09fi
@@ -448,35 +448,163 @@
 tion
-Provider cnxProvider = null
+ connection = DriverManager.getConnection(%22jdbc/url/to/database%22);%0D%0A%09%09final SingleConnectionProvider cnxProvider = new SingleConnectionProvider(connection)
 ;%0D%0A%09

improve example