Db

A simple wrapper around the JDBC API. Currently used for testing. Features:
  • No checked exceptions
  • Easy to use, fluent API


Methods
static RuntimeException convert(Exception e)
Convert a checked exception to a runtime exception.
static RuntimeException convert(Exception e)
Convert a checked exception to a runtime exception.
Parameters:
e - the checked exception
Returns:
the runtime exception
static List query(ResultSet rs)
Read a result set.
static List query(ResultSet rs) throws SQLException
Read a result set.
Parameters:
rs - the result set
Returns:
a list of maps
Db(Connection conn)
Create a database object using the given connection.
Db(Connection conn)
Create a database object using the given connection.
Parameters:
conn - the database connection
void close()
Close the database connection.
void close()
Close the database connection.
void commit()
Commit a pending transaction.
void commit()
Commit a pending transaction.
void execute(String sql)
Execute a SQL statement.
void execute(String sql)
Execute a SQL statement.
Parameters:
sql - the SQL statement
Db.Prepared prepare(String sql)
Prepare a SQL statement.
Db.Prepared prepare(String sql)
Prepare a SQL statement.
Parameters:
sql - the SQL statement
Returns:
the prepared statement
List query(String sql)
Execute a SQL statement.
List query(String sql)
Execute a SQL statement.
Parameters:
sql - the SQL statement
Returns:
a list of maps
void setAutoCommit(boolean autoCommit)
void setAutoCommit(boolean autoCommit)