Class Db

java.lang.Object
org.h2.test.db.Db

public class Db extends Object
A simple wrapper around the JDBC API. Currently used for testing. Features:
  • No checked exceptions
  • Easy to use, fluent API
  • Constructor Details

    • Db

      public Db(Connection conn)
      Create a database object using the given connection.
      Parameters:
      conn - the database connection
  • Method Details

    • prepare

      public Db.Prepared prepare(String sql)
      Prepare a SQL statement.
      Parameters:
      sql - the SQL statement
      Returns:
      the prepared statement
    • execute

      public void execute(String sql)
      Execute a SQL statement.
      Parameters:
      sql - the SQL statement
    • query

      public List<Map<String,Object>> query(String sql)
      Execute a SQL statement.
      Parameters:
      sql - the SQL statement
      Returns:
      a list of maps
    • close

      public void close()
      Close the database connection.
    • setAutoCommit

      public void setAutoCommit(boolean autoCommit)
    • commit

      public void commit()
      Commit a pending transaction.